From ee7c1b1bd8016bb2ec1029aeebc39af977cd1f5a Mon Sep 17 00:00:00 2001 From: Laura Martin Date: Wed, 8 Jan 2025 09:48:20 +0000 Subject: [PATCH] fixup! Use endpoint as default connection option (ADR-119) --- ably/options.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ably/options.go b/ably/options.go index bd5c7bac..013885fd 100644 --- a/ably/options.go +++ b/ably/options.go @@ -63,12 +63,14 @@ var defaultOptions = clientOptions{ LogLevel: LogWarning, // RSC2 } +var nonprodRegexp = regexp.MustCompile(`^nonprod:(.*)$`) + func defaultFallbackHosts() []string { return endpointFallbacks("main", "ably-realtime.com") } func getEndpointFallbackHosts(endpoint string) []string { - if match := regexp.MustCompile(`^nonprod:(.*)$`).FindStringSubmatch(endpoint); match != nil { + if match := nonprodRegexp.FindStringSubmatch(endpoint); match != nil { namespace := match[1] return endpointFallbacks(namespace, "ably-realtime-nonprod.com") } @@ -504,7 +506,7 @@ func (opts *clientOptions) getEndpoint() string { return endpoint } - if match := regexp.MustCompile(`^nonprod:(.*)$`).FindStringSubmatch(endpoint); match != nil { + if match := nonprodRegexp.FindStringSubmatch(endpoint); match != nil { namespace := match[1] return fmt.Sprintf("%s.realtime.ably-nonprod.net", namespace) }