Skip to content

Commit ee7c1b1

Browse files
committed
fixup! Use endpoint as default connection option (ADR-119)
1 parent 842bd77 commit ee7c1b1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ably/options.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,14 @@ var defaultOptions = clientOptions{
6363
LogLevel: LogWarning, // RSC2
6464
}
6565

66+
var nonprodRegexp = regexp.MustCompile(`^nonprod:(.*)$`)
67+
6668
func defaultFallbackHosts() []string {
6769
return endpointFallbacks("main", "ably-realtime.com")
6870
}
6971

7072
func getEndpointFallbackHosts(endpoint string) []string {
71-
if match := regexp.MustCompile(`^nonprod:(.*)$`).FindStringSubmatch(endpoint); match != nil {
73+
if match := nonprodRegexp.FindStringSubmatch(endpoint); match != nil {
7274
namespace := match[1]
7375
return endpointFallbacks(namespace, "ably-realtime-nonprod.com")
7476
}
@@ -504,7 +506,7 @@ func (opts *clientOptions) getEndpoint() string {
504506
return endpoint
505507
}
506508

507-
if match := regexp.MustCompile(`^nonprod:(.*)$`).FindStringSubmatch(endpoint); match != nil {
509+
if match := nonprodRegexp.FindStringSubmatch(endpoint); match != nil {
508510
namespace := match[1]
509511
return fmt.Sprintf("%s.realtime.ably-nonprod.net", namespace)
510512
}

0 commit comments

Comments
 (0)