Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

$location does not parse query portion of URL correctly when in non-html5 mode. #15856

Closed
@ed-at-work

Description

@ed-at-work

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions