@websdk/rhumb
Advanced tools
Comparing version 0.3.8 to 0.3.9-support-root-paths.1
@@ -65,6 +65,2 @@ (function (global, factory) { | ||
function isArr(inst) { | ||
return inst instanceof Array; | ||
} | ||
function create() { | ||
@@ -79,3 +75,3 @@ var router = {}, | ||
if (isArr(part)) { | ||
if (Array.isArray(part)) { | ||
node.leaf = fn; | ||
@@ -86,12 +82,14 @@ updateTree(part, node, fn); | ||
if (!part) { | ||
return; | ||
} | ||
if (!part) return; | ||
if (part.type == "fixed") { | ||
node["fixed"] || (node["fixed"] = {}); | ||
if (part.type === "fixed") { | ||
node.fixed || (node.fixed = {}); | ||
peek = node.fixed[part.input] || (node.fixed[part.input] = {}); | ||
} else if (part.type == "var") { | ||
if (peek.leaf && !more) { | ||
throw new Error("Ambiguity"); | ||
} | ||
} else if (part.type === "var") { | ||
if (node['var']) { | ||
if (node['var'].name == part.input) { | ||
if (node['var'].name === part.input) { | ||
peek = node['var']; | ||
@@ -137,3 +135,3 @@ } else { | ||
var split = path.split("?").filter(falsy), | ||
parts = split[0].split("/").filter(falsy), | ||
parts = ['/'].concat(split[0].split("/").filter(falsy)), | ||
params = parseQueryString(split[1]), | ||
@@ -171,10 +169,4 @@ match = findIn(parts, tree); | ||
bracks = /^[)]+/; | ||
return ~ptn.indexOf('(') ? parseOptional(ptn) : parsePtn(ptn); | ||
if (ptn.trim() == "/") { | ||
return [{ | ||
type: "fixed", | ||
input: "" | ||
}]; | ||
} | ||
function parseVar(part) { | ||
@@ -231,3 +223,3 @@ var match = part.match(variable); | ||
function parsePtn(ptn) { | ||
return ptn.split("/").filter(falsy).map(function (d) { | ||
return ['/'].concat(ptn.split("/")).filter(falsy).map(function (d) { | ||
if (variable.test(d)) { | ||
@@ -250,7 +242,6 @@ return parseVar(d); | ||
len = ptn.length, | ||
curr, | ||
onePart = true; | ||
while (onePart && i < len) { | ||
curr = ptn[i]; | ||
var curr = ptn.charAt(i); | ||
@@ -272,3 +263,3 @@ switch (curr) { | ||
if (!onePart) { | ||
var next = parseOptional(ptn.substr(i + 1)); | ||
var next = parseOptional(ptn.substr(i + 1)).slice(1); | ||
@@ -282,8 +273,2 @@ if (next.length) { | ||
} | ||
if (ptn.indexOf("(") == -1) { | ||
return parsePtn(ptn); | ||
} | ||
return parseOptional(ptn); | ||
} | ||
@@ -290,0 +275,0 @@ |
{ | ||
"name": "@websdk/rhumb", | ||
"version": "0.3.8", | ||
"version": "0.3.9-support-root-paths.1", | ||
"description": "URL routing in js", | ||
@@ -5,0 +5,0 @@ "main": "lib/rhumb.js", |
Sorry, the diff of this file is not supported yet
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
15501
225