Skip to content

Commit

Permalink
Merge pull request #114 from krasimir/pr/110
Browse files Browse the repository at this point in the history
Pr/110
  • Loading branch information
Krasimir Tsonev authored Apr 21, 2017
2 parents c683fd6 + a44e74f commit a8831c7
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 266 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.6.2

* Fixing a bug in IE9 [#110](https://github.com/krasimir/navigo/pull/110)

## 4.6.1

* Using relative URLs in navigation [#109](https://github.com/krasimir/navigo/issues/109)
Expand Down
20 changes: 19 additions & 1 deletion lib/navigo.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/navigo.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/navigo.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/navigo.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "navigo",
"version": "4.6.1",
"version": "4.6.2",
"description": "A simple vanilla JavaScript router with a fallback for older browsers",
"main": "lib/navigo.js",
"jsnext:main": "src/index.js",
Expand Down
25 changes: 24 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,24 @@ function manageHooks(handler, route, params) {
handler();
};

function isHashedRoot(url, useHash, hash) {
if (isPushStateAvailable() && !useHash) {
return false;
}

if (!url.match(hash)) {
return false;
}

let split = url.split(hash);

if (split.length < 2 || split[1] === '') {
return true;
}

return false;
};

Navigo.prototype = {
helpers: {
match,
Expand Down Expand Up @@ -247,7 +265,12 @@ Navigo.prototype = {
handler(m.params, GETParameters);
}, m.route, m.params);
return m;
} else if (this._defaultHandler && (onlyURL === '' || onlyURL === '/' || onlyURL === this._hash)) {
} else if (this._defaultHandler && (
onlyURL === '' ||
onlyURL === '/' ||
onlyURL === this._hash ||
isHashedRoot(onlyURL, this._useHash, this._hash)
)) {
manageHooks(() => {
this._lastRouteResolved = { url: onlyURL, query: GETParameters };
this._defaultHandler.handler(GETParameters);
Expand Down
Loading

0 comments on commit a8831c7

Please sign in to comment.