-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
[Bug]: Firefox not preserving fragment after context.route()
interception
#34518
Comments
As I suspected in your sample code, the issue lies in the line: await context.route("**/*", lambda route, request: route.continue_(url=request.url)) specifically route.continue_(url=request.url)) URL fragments (the URL hash) is not intended to be preserved when communicating with a server, thus our routing does not represent them.
From Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing: RFC 7230 When the lambda executes, For your particular example, you can preserve the full URL by not rewriting the URL in the request: await context.route("**/*", lambda route, request: route.continue_()) |
Sorry to re-alive this issue, but I just noticed that the Firefox browser type seems to be the only one that drops the hash; Chromium and Webkit keep this, and this should probably be consistent across all browsers to avoid surprises. Also, while not my current use case, preserving the hash when rerouting requests could be useful if one needed to test client-side behaviour that depends on the URL fragment in a context where service workers/the geolocation API needs to be disabled. (Specifically, useful for prototyping exploits against domains which are hosted over HTTP, sometimes seen in CTFs, where it's common to deploy the challenge server on localhost for testing). |
I'm sorry, you're right. Firefox will drop the fragment when a route intercepts the message, but Chromium and WebKit do not. |
context.route()
interceptioncontext.route()
interception
Version
1.49.1
Steps to reproduce
Expected behavior
I expect to see the hash preserved after navigation.
Actual behavior
The hash is gone.
Additional context
No response
Environment
The text was updated successfully, but these errors were encountered: