Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6371)

Unified Diff: chrome/browser/resources/settings/route.js

Issue 2518763002: MD Settings: Allow trailing slashes in otherwise valid URLs. (Closed)
Patch Set: Fix case of / Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/settings/route.js
diff --git a/chrome/browser/resources/settings/route.js b/chrome/browser/resources/settings/route.js
index 082a46d3015bbb5cc8493b9a4b3b5967eeef5102..717603df763c7713ae4c020cd9bba071dca0f76a 100644
--- a/chrome/browser/resources/settings/route.js
+++ b/chrome/browser/resources/settings/route.js
@@ -238,17 +238,18 @@ cr.define('settings', function() {
};
/**
- * Returns the matching canonical route, or null if none matches.
* @param {string} path
- * @return {?settings.Route}
+ * @return {?settings.Route} The matching canonical route, or null if none
+ * matches.
*/
var getRouteForPath = function(path) {
// TODO(tommycli): Use Object.values once Closure compilation supports it.
var matchingKey = Object.keys(Route).find(function(key) {
- return Route[key].path == path;
+ // Allow trailing slash in paths.
+ return Route[key].path == (path == '/' ? path : path.replace(/\/$/, ''));
dpapad 2016/11/23 22:57:20 As I am adding tests, I realized that getRouteForP
});
- return Route[matchingKey] || null;
+ return !!matchingKey ? Route[matchingKey] : null;
tommycli 2016/11/23 22:33:46 I assume doing Route[undefined] is bad? (when ther
dpapad 2016/11/23 22:57:20 Yes. The effective behavior was the same, a fals-y
};
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698