-
Notifications
You must be signed in to change notification settings - Fork 26.1k
Querystring removed when useHash is true #36688
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
Comments
|
Hi @MathewBerg - The
The way to set parameters using the hash strategy would be http://localhost:4200/#/example?param=value. Can you format your URL that way or is there some reason that isn't possible? |
|
@atscott unfortunately not because that does not get passed along in the referer header to external services. |
|
Hmm, I'm not really sure what to recommend other than experiment with implementing your own |
|
Sorry, perhaps I'm not being clear. I don't want to change any of the order. When I go to http://localhost:4200/?param=value#/example I simply do not want to have it redirect to http://localhost:4200/#/example or http://localhost:4200/#/example?param=value I need my referer to look like this: http://localhost:4200/?param=value for all pages in my application. |
|
Right, I understand the issue but it does involve putting the query params before the path. As I mentioned before, the |
|
Ah ok that makes a little more sense. I actually think there should be an option to handle this sort of url: http://localhost:4200/?param=value#/example?hashQueryParam=value Where the querystring section is completely ignored. I may need to roll my own LocationStrategy as you said, I'll look into that. I appreciate the responses. |
|
@atscott I was able to extend the hash_location_strategy and did this It allows a url like this: http://localhost:4200/?queryString#/path?hashQueryString= I'd love to get this option into angular itself but would need suggestions on how to enhance the hash location strategy maybe? Or I can just keep this for myself. Once again thanks for looking into it and responding. |
|
Hey @MathewBerg - I'm happy to hear you were able to get it working! As for adding it as an option on I'll at least leave this report open for now for discoverability. |
|
Just for myself and prosperity (thanks to @MathewBerg): In ParameterHashLocationStrategy.ts: In app.module.ts: This is working perfectly! @atscott +1 on the community support :) |
|
After further investigation, this is actually working as intended. There are three possible solutions here:
|
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
🐞 bug report
Affected Package
Not sure, I'm guessing core.
Is this a regression?
Nope
Description
When useHash is set to true the querystring is removed on page load and not maintained when navigating.🔬 Minimal Reproduction
For the router set useHash to true. Then if you load the page such as
http://localhost:4200/?param=value#/example
The querystring gets removed so the new url is
http://localhost:4200/#/example
https://stackblitz.com/...🔥 Exception or Error
While I am completely fine with moving things forward we have a lot of other systems that do reporting on ours. Most of these are on various api calls. We have to use the useHash = true strategy as we need the referer to not include the routes. At the same time there's reporting done on parameters in the querystring that get passed via the referer as well. I am unable to change those systems unfortunately and so I was expecting an option to preserve the query string to be something I could set globally. I know I can specify it for each route but that doesn't handle the page load scenario.
🌍 Your Environment
Angular Version:
Anything else relevant?
The text was updated successfully, but these errors were encountered: