diff --git a/configuration/environment.go b/configuration/environment.go index 00deccf..01897b1 100644 --- a/configuration/environment.go +++ b/configuration/environment.go @@ -28,7 +28,7 @@ func addSubdomainToApiUrlEnvironment(environment Environment, subdomain string) newEnvironment := apiUrl - regex := regexp.MustCompile("^[0-9a-z]{8,11}$") + regex := regexp.MustCompile("^[0-9a-z]+$") if regex.MatchString(subdomain) { merchantApiUrl, _ := url.Parse(apiUrl) diff --git a/test/configuration_api_test.go b/test/configuration_api_test.go index baeaafc..780606e 100644 --- a/test/configuration_api_test.go +++ b/test/configuration_api_test.go @@ -18,9 +18,10 @@ func TestShouldCreateConfigurationWithSubdomain(t *testing.T) { subdomain string expectedUrl string }{ - {"123dmain", "https://123dmain.api.sandbox.checkout.com"}, - {"123domain", "https://123domain.api.sandbox.checkout.com"}, - {"1234domain", "https://1234domain.api.sandbox.checkout.com"}, + {"a", "https://a.api.sandbox.checkout.com"}, + {"ab", "https://ab.api.sandbox.checkout.com"}, + {"abc", "https://abc.api.sandbox.checkout.com"}, + {"abc1", "https://abc1.api.sandbox.checkout.com"}, {"12345domain", "https://12345domain.api.sandbox.checkout.com"}, } @@ -44,9 +45,10 @@ func TestShouldCreateConfigurationWithBadSubdomain(t *testing.T) { expectedUrl string }{ {"", "https://api.sandbox.checkout.com"}, - {"123", "https://api.sandbox.checkout.com"}, - {"123bad", "https://api.sandbox.checkout.com"}, - {"12345domainBad", "https://api.sandbox.checkout.com"}, + {" ", "https://api.sandbox.checkout.com"}, + {" - ", "https://api.sandbox.checkout.com"}, + {"a b", "https://api.sandbox.checkout.com"}, + {"ab c1", "https://api.sandbox.checkout.com"}, } for _, tc := range testCases {