This is a complete re-write of the router. I decided to be a bad guy and kill/change some features. This is in favor of having cleaner code and I hope more stable implementation. The library was also doing bunch of assumptions for the root of your application which proved to be buggy and non-deterministic. So I'm removing this logic and asking you to set the root of your application.
- Hash-based support for older browsers
pause
andresume
. There isshouldResolve
in thenavigate
method instead.historyAPIUpdateMethod
method. It's now an option of thenavigate
method.helpers
methoddisableIfAPINotAvailable
method
- The
navigate
method now accepts options as a second argument which are there to cover more use cases. - There is
data-navigo-options
HTML attributes for your links so you can pass options to thenavigate
method.
- Change the initialization of the router to accept a single argument - the root of your application.
- Checkout your handlers if they read data from a parameterized URL or a GET param. If so make sure that they get the data from the single object passed to the function (an object of type
Match
)wheretype Match = { url: string; queryString: string; route: Route; data: Object | null; // data coming in the URL params: Object | null; // data coming in the query string };
Route
istype Route = { path: string; handler: Function; hooks: RouteHooks; };
- If you are using
historyAPIUpdateMethod
you'll need to pass ahistoryAPIMethod
field to the options of navigate. For example:router.navigate('/foo/bar', { historyAPIMethod: 'replaceState' })
- I hope you didn't use
router.helpers
but if you do explore the alternatives:router.match -> router._matchRoute router.root -> router.root router.clean -> router._clean router.getOnlyURL -> router.extractGETParameters
- If you used the
pause
andresume
methods you have to migrate your app to useshouldResolve
param of thenavigate
method. Or in other words when navigating to define whether you want to have route handling or not. Example:router.navigate('/foo/bar', { shouldResolve: false });
lastRouteResolved
becomeslastResolved
and it returns an object of typeMatch
. Checkout above. (ornull
if there is no resolved URL so far)
Open in new tab when Ctrl-key is pressed (#199)
Fixing the behavior of the hooks #182 #174
Make sure that the leave
hook receives the URL params.
unpkg as CDN.
When using a data-navigo
links we now read from the href
attribute only. The router is not using pathname
anymore. I again got the pros and cons of both approaches and I see that using pathname
actually does not make a lot of sense now.
Resolving the route when we use hash based URL and have no dynamic route #162
Fixing the behavior of getOnlyURL
function.
The lastRouteResolved
now returns a name
property for the named routes.
Adding a new API method historyAPIUpdateMethod
.
Sending matched route parameters to the general hooks. #137
Adding already
hook. #136
Good call by Daniel Bernhard that my updates on the clear
method actually breaks the links with data-navigo
. This release fixes that.
It looks like calling History push or replace state doesn't trigger a popstate event. So we indeed have to call resolve
. This version fixes that and navigate
works again.
Issue #128 made me rethink how Navigo handles routes. The route matching is based on regular expressions and one of them was not quite ok. That's now fixed as part of this latest release. However, these updates change how Navigo uses the registered routes so it may break your app.
- Adding generic hooks + leave hook #107.
- Clear the
navigate
method. It is not callingresolve
automatically. Related to #115.
- Making sure that
generate
doesn't fail if there's a regex as a route #125
- Proper handling of the encoded URL parameter #116
- Fixing the bug described in #122
- Adding
getLinkPath
function to cover #120
- Fixing a bug in IE9 #110
- Using relative URLs in navigation #109
- Parameters from the parameterized routes are sent to hooks' handlers #108
- Fixing a bug under IE9 #104
- A bug fix for #96 which was about a proper extracting of the GET parameters
- Adding
lastRouteResolved
public API (#101)
- Providing an API for case insensitive route handling (#100)
- #97 - similar to #95 we are now using
addEventListener
when listening for browser API events.
- #95 - keeping the already defined handler of
onhashchange
- A path because of the latest release. It covers the case where we are using a custom hash. #92
origin/master
- Fixing #87
- Make sure we have a function when using named routes #86 (by Tobias Nyholm (@Nyholm))
- Support of custom hash string like
#!
for example. Read the docs for more information.
- Fixing #82.
- Adding
off
API method #72.
- Fixing #77.
That's a minor but a breaking change. The generate
method now outputs proper strings base on the useHash
parameter. Or in other words if the router is using hash based routing the generated URLs contain #
in the beginning.
- Proper initialization of the root when using
useHash = true
- Minor fix while resolving hash based URLs (for Firefox)
- Adding a
resume
method which is same as.pause(false)
..pause
now acts as.pause(true)
by default.
- Fixing #63.
- Support of hooks in named routes. (#60)
- Merging #58 where we can prevent the handler calling from a before hook.
- Another try fixing #57 - now if we have
noHash=false
the hash part of the URL is removed and we are no longer considering it while comparing the last resolved URL.
- Fixing #57 - making sure that we keep the last resolved url when we have the
notFound
handler resolves.
- Fixing #56 - When a
/
is given as a path it is considered as a default route handler.
- Start using
onhaschange
API as a default for hash based routing. - Using karma as a test runner.
- Fixing the case where route handlers are not fired when only the query string part of the URL is changed (#53)
- hooks support.