Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update DNS Merchant regular expression length #148

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading