New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enforce a router's root
as its mount point
#1198
Conversation
This enforces routers with a specified `root` to only consider paths as matching its route handles if that path is semantically within the router's `root` path. For example: router.set('root', '/app/'); router.hasRoute('/app/'); // => true router.hasRoute('/app/foo'); // => true router.hasRoute('/bar/'); // => false This change fixes some issues with paths being erroneously considered matching even when they were not semantically within the router's `root` path. The `getPath()` method now returns the _full_ current path, whereas before it returned the current path relative to the router's `root`. These changes will break backwards compatibility with some apps, but fix some fundamental issues with how Y.Router handled `root` paths. Fixes yui#1083
@@ -482,7 +555,7 @@ routerSuite.add(new Y.Test.Case({ | |||
|
|||
router.route('/hashpath', function (req) { | |||
test.resume(function () { | |||
Assert.areSame('/hashpath', req.path); | |||
Assert.areSame('/foo/hashpath', req.path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed test's expected value because req.path
now contains the full URL, and is no longer relative to the router's root
.
Looks good to me. Let's be sure to call out the backcompat breakage with |
👍 I love this change. |
This enforces routers with a specified
root
to only consider paths as matching its route handles if that path is semantically within the router'sroot
path. For example:This change fixes some issues with paths being erroneously considered matching even when they were not semantically within the router's
root
path.The
getPath()
method now returns the full current path, whereas before it returned the current path relative to the router'sroot
. This mean thatreq.path
is now the full path and is no long relative to the router'sroot
.These changes will break backwards compatibility with some apps, but fix some fundamental issues with how Y.Router handled
root
paths.Fixes #1083