documentcloud/backbone — Issue #966: Navigate() appending to current path instead of replacing (routeStripper issue)
Author: Paton
Created: 2012-02-06 22:13:38+00:00
State: open

router.navigate 'thread/' +Math.floor(Math.random()*11)
router.navigate '/thread/' +Math.floor(Math.random()*11)

The result of calling either of thesemethods multiple times is:

1st time: /thread/2
2nd time: /thread/thread/7
3rd time: /thread/thread/thread/4
etc

The expected result is

1st time: /thread/2
2nd time: /thread/7
3rd time: /thread/4

I solved this problem on my end by using the navigate function with the leading slash, ie: "/thread/[number]" and removing the routeStripper regex from backbone.js source.

I also expected router.navigate("") or router.navigate("/") to set the URL to the root, but instead the URL just doesn't change. Is this a bug, or am I misusing the navigate method?