-
-
Notifications
You must be signed in to change notification settings - Fork 736
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
ignoreQueryPrefix should also ignore # character #222
Comments
In general, abusing the hash for a query string is a really bad idea - pages should either redirect (iow, in IE <= 8), or use pushState. What's your use case? |
I have a web app with some state that I would like to persist in the url. This generally consists of 2 or 3 variables which can be easily represented as a query string. Putting it in the hash allows the urls to be bookmarkable, and lets me easily update those variables when the forward/back buttons on the browser are pressed. I am indeed using pushState/replaceState. Additionally, I am upgrading a website that used dojo/hash and dojo/io-query to do exactly this, and would like to be able to keep the same urls as before. |
If this were to be added, it'd need a separate option - ignoreAnchorPrefix or similar. For the moment, |
The way I have my code set up, the query string that I need parsed may or may not include the hash character, so I have a helper function to check and remove the prefix. However, I really like your suggestion of using String.slice(1) whenever I am reading directly from location.hash. It also works when the hash is an empty string. Thanks for the suggestion. |
I'll leave it open in case others have the same request and can supply use cases. |
I agree that hash should not be used. But facebook oauth uses the hash. It returns something like this:
The slice(1) is good. Just sharing that someone huge like facebook abuses hash like this, and that queryString lib does support ignoring first prefix - https://www.npmjs.com/package/query-string |
Oh wow google and dropbox also does this when redirect_uri on their oauth settings is localhost: Google:
Dropbox:
|
It’s not relevant who does a bad thing; the reputation of specific companies can’t possibly change that a bad thing is bad. |
Agreed. Just sharing. |
@Noitidart it really isn't abusing hash. In fact, it's the correct implementation because you're probably requesting implicit grant type and the callback url with query params would mean it'd be part of the request however hash are usually for browsers only. |
Interesting thanks @shri3k I also found that
I ended up having to use urijs because a bunch of oauth services, (facebook, google, etc) are using hash fragment. |
I would like to be able to parse location.hash like this module does: https://www.npmjs.com/package/query-string
Currently, only the ? character is ignored when the ignoreQueryPrefix option is set.
The text was updated successfully, but these errors were encountered: