-
Notifications
You must be signed in to change notification settings - Fork 151
fix: use String.replace() instead of replaceFirst() in createBaseURL #1952
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -58,6 +58,21 @@ public void testLivePalUrlWithPrefix() { | |||||||||||||||||||||||||||||||||||||||||||||||||
| assertEquals(expectedUrl, actualUrl); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| @Test | ||||||||||||||||||||||||||||||||||||||||||||||||||
| public void testLivePalUrlOnlyMatchesLiteralDots() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| config.setLiveEndpointUrlPrefix("123456789-company"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // This URL matches pal-test.adyen.com structurally but has non-dot separators. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // The old replaceFirst() would have incorrectly matched it (dots as wildcards). | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // String.replace() does exact literal matching so the pal- block leaves it unchanged. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // The final fallback still converts -test to -live as expected. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| String urlWithNonDots = "https://pal-testXadyenYcom/pal/servlet/v52/initiate"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| String expectedUrl = "https://pal-liveXadyenYcom/pal/servlet/v52/initiate"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| String actualUrl = service.createBaseURL(urlWithNonDots); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| assertEquals(expectedUrl, actualUrl); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+61
to
+74
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test case
Suggested change
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated the test to use pal-testXadyenYcom so the URL structurally |
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| @Test | ||||||||||||||||||||||||||||||||||||||||||||||||||
| public void testLivePalUrlWithoutPrefix() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| String testUrl = "https://pal-test.adyen.com/pal/servlet/v52/initiate"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this change correctly fixes the regex wildcard issue for the
pal-block, the same issue exists in theautheblock (around line 94 in the full file), which still usesreplaceFirst()with a search string containing literal dots (https://test.adyen.com/). Please consider updating that block as well to ensure consistent and correct URL transformation across all service types.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in the latest commit.