can-route
Advanced tools
Comparing version 3.2.2 to 3.2.3
@@ -195,7 +195,8 @@ /*jshint -W079 */ | ||
var keys = names.concat(Object.keys(defaults)).sort(); | ||
var sameMapKeys = !diff(existingKeys, keys).length; | ||
var sameDefaultValues = !diffObject(r.defaults, defaults).length; | ||
//the regex removes the trailing slash | ||
var matchingRoutesWithoutTrailingSlash = r.route.replace(/\/$/, "") === url.replace(/\/$/, ""); | ||
if (sameMapKeys && sameDefaultValues) { | ||
if (sameMapKeys && sameDefaultValues && !matchingRoutesWithoutTrailingSlash) { | ||
dev.warn('two routes were registered with matching keys:\n' + | ||
@@ -202,0 +203,0 @@ '\t(1) route("' + r.route + '", ' + JSON.stringify(r.defaults) + ')\n' + |
{ | ||
"name": "can-route", | ||
"version": "3.2.2", | ||
"version": "3.2.3", | ||
"description": "", | ||
@@ -55,6 +55,6 @@ "homepage": "", | ||
"devDependencies": { | ||
"can-stache-key": "^0.0.4", | ||
"can-define": "^1.3.3", | ||
"can-list": "^3.2.0", | ||
"can-map": "^3.3.1", | ||
"can-stache-key": "^0.1.0", | ||
"done-serve": "^0.2.0", | ||
@@ -61,0 +61,0 @@ "jshint": "^2.9.1", |
@@ -1124,2 +1124,29 @@ /* jshint asi:true */ | ||
test("should not be display warning for matching keys when the routes do not match (#99)", function () { | ||
expect(1); | ||
var oldlog = dev.warn; | ||
var expectedWarningText = 'two routes were registered with matching keys:\n' + | ||
'\t(1) route("login", {"page":"auth"})\n' + | ||
'\t(2) route("signup", {"page":"auth"})\n' + | ||
'(1) will always be chosen since it was registered first'; | ||
dev.warn = function(text) { | ||
ok(text === expectedWarningText, text) | ||
}; | ||
//should warn | ||
canRoute("login", { "page":"auth" }); | ||
canRoute("signup", { "page":"auth" }); | ||
//should not warn | ||
canRoute("login2/", { "page":"auth2" }); | ||
canRoute("login2", { "page":"auth2" }); | ||
//should not warn | ||
canRoute("login3", { "page":"auth3" }); | ||
canRoute("login3", { "page":"auth3" }); | ||
dev.warn = oldlog; | ||
}); | ||
test("setting route.data with the same map doesn't add the decorator function multiple times", function () { | ||
@@ -1126,0 +1153,0 @@ var oldData = canRoute.data; |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
100261
2780