redux-router-kit
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "redux-router-kit", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Routing tools for Redux/React", | ||
@@ -8,3 +8,3 @@ "main": "lib/index.js", | ||
"test": "ava test", | ||
"prebuild": "mkdir -p lib", | ||
"prebuild": "rm -rf lib && mkdir -p lib", | ||
"build": "babel src --out-dir lib", | ||
@@ -11,0 +11,0 @@ "prepublish": "npm run build", |
@@ -42,7 +42,6 @@ import pathToRegExp from 'path-to-regexp'; | ||
const mapUrlToRoute = (urlAndQueryString, routes) => { | ||
const mapUrlToRoute = (fullUrl, routes) => { | ||
const querySeparatorIndex = urlAndQueryString.indexOf('?'); | ||
const url = urlAndQueryString.substring(0, querySeparatorIndex >= 0 ? querySeparatorIndex : urlAndQueryString.length); | ||
const queryStringAndHash = querySeparatorIndex >= 0 ? urlAndQueryString.substring(querySeparatorIndex) : ''; | ||
const urlWithQueryString = fullUrl.split('#')[0]; | ||
const url = urlWithQueryString.split('?')[0]; | ||
@@ -53,4 +52,4 @@ for (let route in routes) { | ||
if (routeMatch) { | ||
const hashIndex = queryStringAndHash.indexOf('#'); | ||
const queryString = hashIndex >= 0 ? queryStringAndHash.split('#')[0] : queryStringAndHash; | ||
const queryStringAndHash = fullUrl.substring(url.length); | ||
const queryString = queryStringAndHash.split('#')[0]; | ||
const query = queryStringParser.parse(queryString); | ||
@@ -57,0 +56,0 @@ return { |
@@ -44,1 +44,15 @@ import test from 'ava'; | ||
}); | ||
test('route with hash', t => { | ||
const routeMatch = mapUrlToRoute('/users#joe', routes); | ||
t.is(routeMatch.route, '/users'); | ||
}); | ||
test('route with hash and query', t => { | ||
const routeMatch = mapUrlToRoute('/users?q=joe#foo', routes); | ||
t.is(routeMatch.route, '/users'); | ||
}); |
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
335344
6885