hash-brown-router
Advanced tools
Comparing version 1.3.0 to 1.3.1
23
index.js
@@ -5,2 +5,3 @@ var pathToRegexp = require('path-to-regexp-with-reversible-keys') | ||
var browserHashLocation = require('./hash-location.js') | ||
require('array.prototype.find') | ||
@@ -47,23 +48,11 @@ module.exports = function Router(hashLocation) { | ||
path = pathParts.path | ||
var queryStringParameters = pathParts.queryString | ||
var matchingRoute = routes.reduce(function(found, route) { | ||
if (found) { | ||
return found | ||
} else { | ||
var matchingRegex = route.exec(path) | ||
if (matchingRegex) { | ||
return { | ||
regexResult: matchingRegex, | ||
route: route | ||
} | ||
} | ||
} | ||
}, null) | ||
var matchingRoute = routes.find("".match, path) | ||
var queryStringParameters = pathParts.queryString | ||
if (matchingRoute) { | ||
var routeParameters = makeParametersObjectFromRegexResult(matchingRoute.route.keys, matchingRoute.regexResult) | ||
var regexResult = matchingRoute.exec(path) | ||
var routeParameters = makeParametersObjectFromRegexResult(matchingRoute.keys, regexResult) | ||
var params = xtend(queryStringParameters, routeParameters) | ||
matchingRoute.route.fn(params) | ||
matchingRoute.fn(params) | ||
} else if (routes.defaultFn) { | ||
@@ -70,0 +59,0 @@ routes.defaultFn(path, queryStringParameters) |
{ | ||
"name": "hash-brown-router", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "A client-side router that only cares about the bits after the #", | ||
@@ -29,9 +29,9 @@ "main": "index.js", | ||
"domready": "^1.0.7", | ||
"path-to-regexp-with-reversible-keys": "^1.0.1", | ||
"tap-browser-color": "^0.1.2", | ||
"tape": "^3.0.1", | ||
"xtend": "^4.0.0" | ||
"tape": "^3.0.1" | ||
}, | ||
"dependencies": { | ||
"path-to-regexp-with-reversible-keys": "^1.0.1" | ||
"array.prototype.find": "^1.0.0", | ||
"path-to-regexp-with-reversible-keys": "^1.0.1", | ||
"xtend": "^4.0.0" | ||
}, | ||
@@ -38,0 +38,0 @@ "testling": { |
A router that is only concerned with single-page apps that want to change state based on the bits of the url after the hash. | ||
[![browser support](https://ci.testling.com/TehShrike/hash-brown-router.png)](https://ci.testling.com/TehShrike/hash-brown-router) | ||
[![Build Status](https://travis-ci.org/TehShrike/hash-brown-router.svg)](https://travis-ci.org/TehShrike/hash-brown-router) | ||
@@ -6,0 +6,0 @@ ## To use |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
3
0
14219
3
360
+ Addedarray.prototype.find@^1.0.0
+ Addedxtend@^4.0.0
+ Addedarray.prototype.find@1.0.0(transitive)
+ Addedxtend@4.0.2(transitive)