Skip to content

Commit

Permalink
Update DNS Merchant regular expression length (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
armando-rodriguez-cko authored Aug 29, 2024
1 parent 10ea262 commit 48169cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion configuration/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 8 additions & 6 deletions test/configuration_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
}

Expand All @@ -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 {
Expand Down

0 comments on commit 48169cb

Please sign in to comment.