Chromium Code Reviews| 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
|
| }; |
| /** |