Skip to content

Commit 4098fa9

Browse files
Update DNS Merchant regular expression length (#148)
1 parent 9fa2793 commit 4098fa9

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

lib/checkout_sdk/environment_subdomain.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ def add_subdomain_to_api_url_environment(environment, subdomain)
2929
api_url = environment.base_uri
3030
new_environment = api_url
3131

32-
# Regex to match a subdomain consisting of 8 to 11 lowercase alphanumeric characters
33-
if subdomain =~ /^[0-9a-z]{8,11}$/
32+
if subdomain =~ /^[0-9a-z]+$/
3433
url_parts = URI.parse(api_url)
3534
new_host = "#{subdomain}.#{url_parts.host}"
3635

spec/checkout_sdk/configuration/configuration_spec.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ class FakeLogger
3131
end
3232

3333
[
34-
%w[123dmain https://123dmain.api.sandbox.checkout.com/],
35-
%w[123domain https://123domain.api.sandbox.checkout.com/],
36-
%w[1234domain https://1234domain.api.sandbox.checkout.com/],
34+
%w[a https://a.api.sandbox.checkout.com/],
35+
%w[ab https://ab.api.sandbox.checkout.com/],
36+
%w[abc https://abc.api.sandbox.checkout.com/],
37+
%w[abc1 https://abc1.api.sandbox.checkout.com/],
3738
%w[12345domain https://12345domain.api.sandbox.checkout.com/]
3839
].each do |subdomain, expected_url|
3940
it "should create configuration with subdomain #{subdomain}" do
@@ -57,11 +58,13 @@ class FakeLogger
5758

5859
[
5960
['', 'https://api.sandbox.checkout.com/'],
60-
%w[123 https://api.sandbox.checkout.com/],
61-
%w[123bad https://api.sandbox.checkout.com/],
62-
%w[12345domainBad https://api.sandbox.checkout.com/]
61+
[' ', 'https://api.sandbox.checkout.com/'],
62+
[' ', 'https://api.sandbox.checkout.com/'],
63+
[' - ', 'https://api.sandbox.checkout.com/'],
64+
['a b', 'https://api.sandbox.checkout.com/'],
65+
['ab bc1', 'https://api.sandbox.checkout.com/']
6366
].each do |subdomain, expected_url|
64-
it 'should create configuration with bad subdomain #{subdomain}' do
67+
it "should create configuration with bad subdomain #{subdomain}" do
6568
environment_subdomain = CheckoutSdk::EnvironmentSubdomain.new(CheckoutSdk::Environment.sandbox, subdomain)
6669

6770
configuration = CheckoutSdk::CheckoutConfiguration.new(

0 commit comments

Comments
 (0)