route-recognizer
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -128,6 +128,3 @@ import map from './route-recognizer/dsl'; | ||
// string. We can find the specificity of compound routes by concatenating these strings | ||
// together, from left to right. After we have looped through all of the segments, | ||
// we convert the string to a number. | ||
specificity.val = ''; | ||
// together, from left to right. | ||
for (var i=0; i<segments.length; i++) { | ||
@@ -155,7 +152,10 @@ var segment = segments[i], match; | ||
specificity.val = +specificity.val; | ||
return results; | ||
} | ||
function isEqualCharSpec(specA, specB) { | ||
return specA.validChars === specB.validChars && | ||
specA.invalidChars === specB.invalidChars; | ||
} | ||
// A State has a character specification and (`charSpec`) and a list of possible | ||
@@ -181,3 +181,2 @@ // subsequent states (`nextStates`). | ||
this.nextStates = []; | ||
this.charSpecs = {}; | ||
this.regex = undefined; | ||
@@ -190,6 +189,2 @@ this.handlers = undefined; | ||
get: function(charSpec) { | ||
if (this.charSpecs[charSpec.validChars]) { | ||
return this.charSpecs[charSpec.validChars]; | ||
} | ||
var nextStates = this.nextStates; | ||
@@ -200,7 +195,3 @@ | ||
var isEqual = child.charSpec.validChars === charSpec.validChars; | ||
isEqual = isEqual && child.charSpec.invalidChars === charSpec.invalidChars; | ||
if (isEqual) { | ||
this.charSpecs[charSpec.validChars] = child; | ||
if (isEqualCharSpec(child.charSpec, charSpec)) { | ||
return child; | ||
@@ -261,3 +252,3 @@ } | ||
return states.sort(function(a, b) { | ||
return b.specificity.val - a.specificity.val; | ||
return (b.specificity.val < a.specificity.val) ? -1 : (b.specificity.val === a.specificity.val) ? 0 : 1; | ||
}); | ||
@@ -350,3 +341,3 @@ } | ||
var currentState = this.rootState, regex = "^", | ||
specificity = {}, | ||
specificity = { val: '' }, | ||
handlers = new Array(routes.length), allSegments = [], name; | ||
@@ -353,0 +344,0 @@ |
@@ -309,6 +309,3 @@ (function() { | ||
// string. We can find the specificity of compound routes by concatenating these strings | ||
// together, from left to right. After we have looped through all of the segments, | ||
// we convert the string to a number. | ||
specificity.val = ''; | ||
// together, from left to right. | ||
for (var i=0; i<segments.length; i++) { | ||
@@ -336,7 +333,10 @@ var segment = segments[i], match; | ||
specificity.val = +specificity.val; | ||
return results; | ||
} | ||
function $$route$recognizer$$isEqualCharSpec(specA, specB) { | ||
return specA.validChars === specB.validChars && | ||
specA.invalidChars === specB.invalidChars; | ||
} | ||
// A State has a character specification and (`charSpec`) and a list of possible | ||
@@ -362,3 +362,2 @@ // subsequent states (`nextStates`). | ||
this.nextStates = []; | ||
this.charSpecs = {}; | ||
this.regex = undefined; | ||
@@ -371,6 +370,2 @@ this.handlers = undefined; | ||
get: function(charSpec) { | ||
if (this.charSpecs[charSpec.validChars]) { | ||
return this.charSpecs[charSpec.validChars]; | ||
} | ||
var nextStates = this.nextStates; | ||
@@ -381,7 +376,3 @@ | ||
var isEqual = child.charSpec.validChars === charSpec.validChars; | ||
isEqual = isEqual && child.charSpec.invalidChars === charSpec.invalidChars; | ||
if (isEqual) { | ||
this.charSpecs[charSpec.validChars] = child; | ||
if ($$route$recognizer$$isEqualCharSpec(child.charSpec, charSpec)) { | ||
return child; | ||
@@ -442,3 +433,3 @@ } | ||
return states.sort(function(a, b) { | ||
return b.specificity.val - a.specificity.val; | ||
return (b.specificity.val < a.specificity.val) ? -1 : (b.specificity.val === a.specificity.val) ? 0 : 1; | ||
}); | ||
@@ -531,3 +522,3 @@ } | ||
var currentState = this.rootState, regex = "^", | ||
specificity = {}, | ||
specificity = { val: '' }, | ||
handlers = new Array(routes.length), allSegments = [], name; | ||
@@ -534,0 +525,0 @@ |
@@ -128,6 +128,3 @@ import map from './route-recognizer/dsl'; | ||
// string. We can find the specificity of compound routes by concatenating these strings | ||
// together, from left to right. After we have looped through all of the segments, | ||
// we convert the string to a number. | ||
specificity.val = ''; | ||
// together, from left to right. | ||
for (var i=0; i<segments.length; i++) { | ||
@@ -155,7 +152,10 @@ var segment = segments[i], match; | ||
specificity.val = +specificity.val; | ||
return results; | ||
} | ||
function isEqualCharSpec(specA, specB) { | ||
return specA.validChars === specB.validChars && | ||
specA.invalidChars === specB.invalidChars; | ||
} | ||
// A State has a character specification and (`charSpec`) and a list of possible | ||
@@ -181,3 +181,2 @@ // subsequent states (`nextStates`). | ||
this.nextStates = []; | ||
this.charSpecs = {}; | ||
this.regex = undefined; | ||
@@ -190,6 +189,2 @@ this.handlers = undefined; | ||
get: function(charSpec) { | ||
if (this.charSpecs[charSpec.validChars]) { | ||
return this.charSpecs[charSpec.validChars]; | ||
} | ||
var nextStates = this.nextStates; | ||
@@ -200,7 +195,3 @@ | ||
var isEqual = child.charSpec.validChars === charSpec.validChars; | ||
isEqual = isEqual && child.charSpec.invalidChars === charSpec.invalidChars; | ||
if (isEqual) { | ||
this.charSpecs[charSpec.validChars] = child; | ||
if (isEqualCharSpec(child.charSpec, charSpec)) { | ||
return child; | ||
@@ -261,3 +252,3 @@ } | ||
return states.sort(function(a, b) { | ||
return b.specificity.val - a.specificity.val; | ||
return (b.specificity.val < a.specificity.val) ? -1 : (b.specificity.val === a.specificity.val) ? 0 : 1; | ||
}); | ||
@@ -350,3 +341,3 @@ } | ||
var currentState = this.rootState, regex = "^", | ||
specificity = {}, | ||
specificity = { val: '' }, | ||
handlers = new Array(routes.length), allSegments = [], name; | ||
@@ -353,0 +344,0 @@ |
{ | ||
"name": "route-recognizer", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "A lightweight JavaScript library that matches paths against registered routes.", | ||
@@ -5,0 +5,0 @@ "author": "Yehuda Katz", |
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
170184
2041