Skip to content

Commit

Permalink
Update DNS Merchant regular expression length (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
armando-rodriguez-cko authored Aug 29, 2024
1 parent 9fa2793 commit 4098fa9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
3 changes: 1 addition & 2 deletions lib/checkout_sdk/environment_subdomain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ def add_subdomain_to_api_url_environment(environment, subdomain)
api_url = environment.base_uri
new_environment = api_url

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

Expand Down
17 changes: 10 additions & 7 deletions spec/checkout_sdk/configuration/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ class FakeLogger
end

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

[
['', 'https://api.sandbox.checkout.com/'],
%w[123 https://api.sandbox.checkout.com/],
%w[123bad https://api.sandbox.checkout.com/],
%w[12345domainBad https://api.sandbox.checkout.com/]
[' ', 'https://api.sandbox.checkout.com/'],
[' ', 'https://api.sandbox.checkout.com/'],
[' - ', 'https://api.sandbox.checkout.com/'],
['a b', 'https://api.sandbox.checkout.com/'],
['ab bc1', 'https://api.sandbox.checkout.com/']
].each do |subdomain, expected_url|
it 'should create configuration with bad subdomain #{subdomain}' do
it "should create configuration with bad subdomain #{subdomain}" do
environment_subdomain = CheckoutSdk::EnvironmentSubdomain.new(CheckoutSdk::Environment.sandbox, subdomain)

configuration = CheckoutSdk::CheckoutConfiguration.new(
Expand Down

0 comments on commit 4098fa9

Please sign in to comment.