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

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

Merged

Conversation

mxschmitt
Copy link
Member

@@ -157,6 +157,10 @@ def url_matches(
base_url = re.sub(r"^http", "ws", base_url)
if base_url:
match = urljoin(base_url, match)
parsed = urlparse(match)
if parsed.path == "":
parsed = parsed._replace(path="/")
Copy link
Member 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
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
Member 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.

@mxschmitt mxschmitt merged commit 00fbc3c into microsoft:main Dec 12, 2024
33 of 38 checks passed
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