mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Simplify Navigation.go, not preserving hash fragments
I looked through the history and it looks like this function was a bit flawed (preserving hash fragments) from the beginning. It has been patched a few times without addressing the underlying issue that we want more than just replacing the pathname. We want to go somewhere else.
This commit is contained in:
@@ -21,10 +21,9 @@ Darkswarm.factory 'Navigation', ($location, $window) ->
|
||||
$window.location.href = $window.location.origin + path
|
||||
|
||||
go: (path)->
|
||||
if path.match /^http/
|
||||
$window.location.href = path
|
||||
else
|
||||
$window.location.pathname = path
|
||||
# The browser treats this like clicking on a link.
|
||||
# It works for absolute paths, relative paths and URLs alike.
|
||||
$window.location.href = path
|
||||
|
||||
reload: ->
|
||||
$window.location.reload()
|
||||
|
||||
@@ -3,7 +3,6 @@ describe 'Navigation service', ->
|
||||
window =
|
||||
location:
|
||||
href: null
|
||||
pathname: null
|
||||
|
||||
beforeEach ->
|
||||
module 'Darkswarm', ($provide) ->
|
||||
@@ -24,5 +23,4 @@ describe 'Navigation service', ->
|
||||
|
||||
it "redirects to paths", ->
|
||||
Navigation.go "/woo/yeah"
|
||||
expect(window.location.pathname).toEqual "/woo/yeah"
|
||||
|
||||
expect(window.location.href).toEqual "/woo/yeah"
|
||||
|
||||
Reference in New Issue
Block a user