This repository was archived by the owner on Apr 12, 2024. It is now read-only.
$location.search() returns undefined when base href does not match URL #16241
Labels
Milestone
8000
I'm submitting a ...
Current behavior:
In our app's
run
function,$location.search()
returnsundefined
.Expected / new behavior:
$location.search()
should return an object, as documented.Minimal reproduction of the problem with instructions:
Serve page at
https://localhost/foo/bar/
include tag
<base href="/baz/">
Use HTML5 location mode.
see http://plnkr.co/edit/RRJMNjo6Viw1NbtNeWfr?p=preview
AngularJS version: 1.5.10
Browser: Chrome 61 | Firefox 57
Anything else:
Oh, this may be a duplicate of #11223. That issue got sidetracked to a discussion of case-sensitivity and then marked as wontfix, but I think that was a tangent unrelated to making search() return properly.
In a way much like #14488 noted for$location.$ $absUrl, the $location.$ $search property may not be initialized before $location.search() is called.
Perhaps the search() method needs to check to see if $$search is undefined, similar to how other functions check for a value for $$path or $$hash, or perhaps when $locationProvider.$get needs to always call$location.$ $parse (which $location.$ $parseLinkUrl declines to do in this condition).
I also noticed that sometime later $location.search() would return properly; I suspect this is related to how $locationProvider.$get adds a watch to $rootScope, but the app's run function probably happens before that digest cycle.
The text was updated successfully, but these errors were encountered: