Skip to content

fix(webSocketRoute): allow no trailing slash in route matching#2687

Merged
mxschmitt merged 2 commits intomicrosoft:mainfrom
mxschmitt:allow-no-trailing-slash-in-websocket
Dec 12, 2024
Merged

fix(webSocketRoute): allow no trailing slash in route matching#2687
mxschmitt merged 2 commits intomicrosoft:mainfrom
mxschmitt:allow-no-trailing-slash-in-websocket

Conversation

@mxschmitt
Copy link
Copy Markdown
Contributor

match = urljoin(base_url, match)
parsed = urlparse(match)
if parsed.path == "":
parsed = parsed._replace(path="/")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_replace seems to be the recommendation as per here.

Copy link
Copy Markdown
Member

@yury-s yury-s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it work in Node.js and other ports?

@mxschmitt
Copy link
Copy Markdown
Contributor Author

Why does it work in Node.js and other ports?

In Node.js we do the same here: https://github.com/microsoft/playwright/blob/16a1552e7490139f295086ab52cc0d7b3901eaac/packages/playwright-core/src/utils/isomorphic/urlMatch.ts#L128

The URL constructor does normalise the URL and add a trailing slash.

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