Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Regex fix to avoid matching a trailing slash. #1677

merged 2 commits into from

4 participants


The default regex '([^/#?]*)' inserted as a placeholder for matching named patterns matches empty components, such as a trailing slash. This means that a pattern such as /foo/:bar/:baz will match /foo/BAR/, while it should only match foo/BAR/BAZ.

Changing the regex to '([^/#?]+)' to require at least one character in the component keeps trailing slashes from matching the specified path.


Can you add some tests for this? Thanks!

saw commented

(this is to fix a regression we found after upgrading)


That should do it.
Wasn't clear if you need build files committed as well? I'm guessing Travis will handle this for the automated tests but not sure.

Thx Eric! (Can never have too many Erics around here.)

@ezequiel ezequiel merged commit 40f7c02 into from


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 4, 2014
  1. Added tests for regex edit.

    Eric authored
This page is out of date. Refresh to see the latest.
2  src/app/js/router.js
@@ -1055,7 +1055,7 @@ Y.Router = Y.extend(Router, Y.Base, {
- return operator === '*' ? '(.*?)' : '([^/#?]*)';
+ return operator === '*' ? '(.*?)' : '([^/#?]+)';
return new RegExp('^' + path + '$');
6 src/app/tests/unit/assets/router-test.js
@@ -1021,6 +1021,12 @@ routerSuite.add(new Y.Test.Case({
Assert.isFalse(check("/:foo/bar", "/baz/quux"));
Assert.isFalse(check("/:foo/bar", "/foo/bar?a=b"));
Assert.isFalse(check("/:foo/bar", "/foo/bar#a"));
+ Assert.isTrue( check("/foo/:foo/:bar/?", "/foo/foo/bar"));
+ Assert.isTrue( check("/foo/:foo/:bar/?", "/foo/foo/bar/"));
+ Assert.isFalse(check("/foo/:foo/:bar/?", "/foo/bar"));
+ Assert.isFalse(check("/foo/:foo/:bar/?", "/foo/bar/"));
+ Assert.isFalse(check("/foo/:foo/:bar/?", "/foo/bar?a=b"));
Something went wrong with that request. Please try again.