Skip to content

Commit 9390bef

Browse files
committed
Fix minor issues
1 parent 9109f3c commit 9390bef

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

lib/adyen/client.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def initialize(ws_user: nil, ws_password: nil, api_key: nil, oauth_token: nil, e
5151

5252
# make sure that env can only be :live, :test, or :mock
5353
def env=(value)
54-
raise ArgumentError, "Invalid value for Client.env: '#{value}'' - must be one of [:live, :test, :mock]" unless %i[
54+
raise ArgumentError, "Invalid value for Client.env: '#{value}' - must be one of [:live, :test, :mock]" unless %i[
5555
live test mock
5656
].include? value
5757

@@ -60,10 +60,7 @@ def env=(value)
6060

6161
# remove 'https' from live_url_prefix if necessary
6262
def live_url_prefix=(value)
63-
unless value.nil?
64-
value['https://'] = '' unless value['https://'].nil?
65-
end
66-
@live_url_prefix = value
63+
@live_url_prefix = value.nil? ? value : value.sub('https://', '')
6764
end
6865

6966
# base URL for API given service and @env

spec/client_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
.to eq('https://myprefix-pal-live.adyenpayments.com/pal/servlet/Payment')
3535
end
3636

37+
it 'does not mutate the original live_url_prefix string' do
38+
prefix = 'https://myprefix'
39+
Adyen::Client.new(env: :live, live_url_prefix: prefix)
40+
expect(prefix).to eq('https://myprefix')
41+
end
42+
3743
it 'sets the version number' do
3844
@shared_values[:client].checkout.version = @shared_values[:version]
3945
expect(@shared_values[:client].checkout.version)

0 commit comments

Comments
 (0)