baobab-router
Advanced tools
Comparing version 2.2.0 to 2.2.1
@@ -73,3 +73,3 @@ 'use strict'; | ||
var hash = url.split('/').map(function (s) { | ||
return s in dyn ? escape(dyn[s]) : s; | ||
return dyn.hasOwnProperty(s) ? escape(dyn[s]) : s; | ||
}).join('/'); | ||
@@ -485,6 +485,7 @@ var query = Object.keys(qry).filter(function (k) { | ||
var match = __doesHashMatch(route.fullPath, baseHash); | ||
var hash = baseHash.replace(/\?.*$/, '').split('/'); | ||
var query = baseHash.replace(/^[^\?]*\??/, ''); | ||
var doCommit = undefined; | ||
var doForceCommit = undefined; | ||
var hash = baseHash; | ||
var path = basePath || ''; | ||
@@ -498,3 +499,3 @@ | ||
if (route.routes && route.routes.some(function (child) { | ||
return _checkHash(hash, route.fullPath, child); | ||
return _checkHash(baseHash, route.fullPath, child); | ||
})) { | ||
@@ -506,5 +507,4 @@ return true; | ||
if (match && route.defaultRoute) { | ||
hash = (hash || '').split('/'); | ||
path = route.fullDefaultPath.split('/').map(function (str, i) { | ||
return str.match(_solver) ? hash[i] || str : str; | ||
return str.match(_solver) ? unescape(hash[i]) || str : str; | ||
}).join('/'); | ||
@@ -521,8 +521,8 @@ | ||
var _ret = function () { | ||
var queryValues = hash.replace(/^[^\?]*\??/, '').split('&').reduce(function (res, str) { | ||
var queryValues = query.split('&').reduce(function (res, str) { | ||
var arr = str.split('='); | ||
var query = (route.query || {})[arr[0]] || {}; | ||
var queryObj = (route.query || {})[unescape(arr[0])] || {}; | ||
var value = unescape(arr[1]); | ||
switch (query.cast) { | ||
switch (queryObj.cast) { | ||
case 'number': | ||
@@ -545,3 +545,3 @@ value = +value; | ||
res[query.match] = value; | ||
res[queryObj.match] = value; | ||
return res; | ||
@@ -558,3 +558,3 @@ }, {}); | ||
if (obj.dynamic) { | ||
update.value = hash.split('/')[route.fullPath.split('/').indexOf(update.value)] || queryValues[update.value]; | ||
update.value = hash[route.fullPath.split('/').indexOf(update.value)] || queryValues[update.value]; | ||
} | ||
@@ -770,3 +770,3 @@ | ||
// Baobab-Router version: | ||
BaobabRouter.version = '2.2.0'; | ||
BaobabRouter.version = '2.2.1'; | ||
@@ -773,0 +773,0 @@ // Expose private methods for unit testing: |
@@ -67,3 +67,3 @@ /** | ||
.split('/') | ||
.map(s => (s in dyn) ? escape(dyn[s]) : s) | ||
.map(s => dyn.hasOwnProperty(s) ? escape(dyn[s]) : s) | ||
.join('/'); | ||
@@ -523,6 +523,7 @@ const query = Object.keys(qry) | ||
const match = __doesHashMatch(route.fullPath, baseHash); | ||
const hash = baseHash.replace(/\?.*$/, '').split('/'); | ||
const query = baseHash.replace(/^[^\?]*\??/, ''); | ||
let doCommit; | ||
let doForceCommit; | ||
let hash = baseHash; | ||
let path = basePath || ''; | ||
@@ -537,3 +538,3 @@ | ||
route.routes && | ||
route.routes.some(child => _checkHash(hash, route.fullPath, child)) | ||
route.routes.some(child => _checkHash(baseHash, route.fullPath, child)) | ||
) { | ||
@@ -545,6 +546,5 @@ return true; | ||
if (match && route.defaultRoute) { | ||
hash = (hash || '').split('/'); | ||
path = route.fullDefaultPath | ||
.split('/') | ||
.map((str, i) => str.match(_solver) ? hash[i] || str : str) | ||
.map((str, i) => str.match(_solver) ? unescape(hash[i]) || str : str) | ||
.join('/'); | ||
@@ -560,11 +560,10 @@ | ||
if (match && !route.defaultRoute) { | ||
const queryValues = hash | ||
.replace(/^[^\?]*\??/, '') | ||
const queryValues = query | ||
.split('&') | ||
.reduce((res, str) => { | ||
const arr = str.split('='); | ||
const query = (route.query || {})[arr[0]] || {}; | ||
const queryObj = (route.query || {})[unescape(arr[0])] || {}; | ||
let value = unescape(arr[1]); | ||
switch (query.cast) { | ||
switch (queryObj.cast) { | ||
case 'number': | ||
@@ -589,3 +588,3 @@ value = +value; | ||
res[query.match] = value; | ||
res[queryObj.match] = value; | ||
return res; | ||
@@ -602,3 +601,3 @@ }, {}); | ||
if (obj.dynamic) { | ||
update.value = hash.split('/')[ | ||
update.value = hash[ | ||
route.fullPath.split('/').indexOf(update.value) | ||
@@ -836,3 +835,3 @@ ] || queryValues[update.value]; | ||
// Baobab-Router version: | ||
BaobabRouter.version = '2.2.0'; | ||
BaobabRouter.version = '2.2.1'; | ||
@@ -839,0 +838,0 @@ // Expose private methods for unit testing: |
{ | ||
"name": "baobab-router", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "A router for Baobab", | ||
@@ -5,0 +5,0 @@ "main": "baobab-router.dist.js", |
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
63753
1436