$location does not parse query portion of URL correctly when in non-html5 mode. #15856
Description
I'm submitting a ...
- [x ] bug report
- feature request
- other (Please do not submit support requests here (see above))
Current behavior:
When the $locationProvider has set html5 mode to false, URLs that follow the RFC for URIs (RFC 3986) and include both a query string portion and a fragment portion in the URI will not have the query string portion set, so $location.search('foo')
is empty. In fact even the documentation for $location
is wrong, since it gives an example like this:
// given URL http://example.com/#/some/path?foo=bar&baz=xoxo
even though the RFC is perfectly clear that a well formed URL looks like this:
URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
(see https://tools.ietf.org/html/rfc3986#appendix-A).
Expected / new behavior:
AngularJS should respect the specification and work properly when the query portion of the URL appears before the fragment portion.
Minimal reproduction of the problem with instructions:
Reproducing the problem is simple on any browser that follows the specification. Attempt to navigate to a URL such as http://example.com/foo?query=bar&baz=topaz#/path/to/angular/route
and you'll find that the $location service does not know about the query parameters in this URL.
Angular version: 1.x.y
I have noticed this problem in 1.5.7 but the same patch applies cleanly to master as of this writing so I assume the problem continues to exist in master as of this issue report.
Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
iOS WKWebView
Anything else:
I have a PR ready to go for this.