Skip to content

fix: join base url and relative path with a single slash - #5738

Merged
DavertMik merged 1 commit into
4.xfrom
fix/amonpage-trailing-slash
Oct 7, 2026
Merged

DavertMik merged 1 commit into
4.xfrom
fix/amonpage-trailing-slash

Conversation

@DavertMik

Copy link
Copy Markdown
Contributor

Problem

Playwright.amOnPage built the URL as:

this.options.url + (!this.options.url.endsWith('/') && url.startsWith('/') ? url : `/${url}`)

When the base url ends with /, it always adds another /:

url config amOnPage(...) Before After
https://todomvc.com/examples/react/dist/ / …/dist/// …/dist/
https://todomvc.com/examples/react/dist/ /#/active …/dist///#/active …/dist/#/active
https://todomvc.com/examples/react/dist/ index.html …/dist//index.html …/dist/index.html

Puppeteer.amOnPage, Playwright's API request method and WebDriver's basic-auth branch concatenated base and path directly, giving // or no separator at all (http://hostlogin).

Fix

All four now use the existing appendBaseUrl util from lib/utils.js. Its trimUrl never stripped the leading slash (url.substr(1) === '/' only matched two-character inputs), so that is fixed too, and trailing slashes on the base are all removed.

Tests

  • New #appendBaseUrl cases in test/unit/utils_test.js.
  • Checked live against todomvc.com with the Playwright helper (table above).

🤖 Generated with Claude Code

Playwright amOnPage produced https://host/app///path whenever the base url
ended with a slash, and Puppeteer/WebDriver concatenated without any
separator. Route all of them through appendBaseUrl and fix its trimUrl,
which never stripped the leading slash.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DavertMik
DavertMik merged commit 0febfc8 into 4.x Oct 7, 2026
14 checks passed
@DavertMik
DavertMik deleted the fix/amonpage-trailing-slash branch October 7, 2026 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants