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:
Maikel Linke
2018-06-15 09:51:43 +10:00
parent 6cf09c936b
commit fb02bdd25a
2 changed files with 4 additions and 7 deletions

View File

@@ -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()

View File

@@ -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"