-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Should $location extract search params from before the #! ? #5964
Comments
well if search isn't working in hashbang mode when there's no hashbang, that sounds like a bug. care to try and submit a patch? It would be good if you could show a jasmine test which fails without a fix first |
Actually, this seems to be from urlResolve.js, where we give an anchor tag the url and get it to parse it for us. So I guess the browser isn't convinced there's a search string either, without the '#/'.... So are you saying that with html5Mode it works as you expect? because it would appear not to |
@caitp I'd be happy to write up a PR, but I need to wait for permission to sign the CLA and provide code to the project. |
@bhollis it's okay, I've realized that we were not actually sending the urlResolve function the entire relative url, and am submitting a fix for this. It might actually make it to the release after all if we defer until tomorrow. |
Before this fix, search queries in hashbang mode were ignored if the hash was not present in the url. This patch corrects this by ensuring that the search query is available to be parsed by urlResolve when the hashbang is not present. Closes angular#5964
Before this fix, search queries in hashbang mode were ignored if the hash was not present in the url. This patch corrects this by ensuring that the search query is available to be parsed by urlResolve when the hashbang is not present. Closes angular#5964
Before this fix, search queries in hashbang mode were ignored if the hash was not present in the url. This patch corrects this by ensuring that the search query is available to be parsed by urlResolve when the hashbang is not present. Closes angular#5964
Before this fix, search queries in hashbang mode were ignored if the hash was not present in the url. This patch corrects this by ensuring that the search query is available to be parsed by urlResolve when the hashbang is not present. Closes angular#5964
Thanks, that's great! |
It looks like that fixes the first case, which is great. What do you think about the slightly weirder second example:
Where there's both a search string before, and after the hash? |
I'm not sure if that's a really valid URL... I'll have to see what people think about it. How are you coming up with a url like that in angular anyway? |
That one's theoretical, but I was assuming it was what would happen if I modified |
If that does happen, I think that's a separate bug to look at. But we should really get a reproduction to be sure |
Before this fix, search queries in hashbang mode were ignored if the hash was not present in the url. This patch corrects this by ensuring that the search query is available to be parsed by urlResolve when the hashbang is not present. Closes angular#5964
…bang mode This reverts commit cad717b. This change causes regressions in existing code and after closer inspection I realized that it is trying to fix an issue that is should not be considered a valid issue. The location service was designed to work against either "hash" part of the window.location when in the hashbang mode or full url when in the html5 mode. This change tries to merge the two modes partially, which is not right. One reason for this is that the search part of window.location can't be modified while in the hashbang mode (a browser limitation), so with this change part of the search object should be immutable and read-only which will only cause more confusion. Relates to #5964
Pretty sure this is still broken |
@nkomp18, this issue is closed. If you think there is still a bug in the latest versions, please open a new bug report (providing the necessary details). |
When not in HTML5 mode, given a URL like this:
$location.search()
produces an empty object, rather than{ bar: 'baz' }
.I understand that it's looking only at the part of the URL following
#!
, but I'm wondering if that's really the correct way to go - it certainly makes it difficult to extract and use those query parameters (without using separate URL parsing code forwindow.location
). Is this just not what$location
is for? The docs say:I'd also expect that given a URL like this, not in HTML5 mode:
I'd expect
$location.search()
to be{ bar: 'baz', qux: 'quux' }
- the merged set of query parameters.The text was updated successfully, but these errors were encountered: