Skip to content
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

Merged
merged 6 commits into from Sep 19, 2013
Merged

Conversation

ericf
Copy link
Member

@ericf ericf commented Sep 16, 2013

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. This mean that req.path is now the full path and is no long 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 #1083

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);
Copy link
Member Author

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.

@rgrove
Copy link
Contributor

rgrove commented Sep 16, 2013

Looks good to me. Let's be sure to call out the backcompat breakage with getPath() and req.path very prominently in the release announcement.

@tivac
Copy link
Contributor

tivac commented Sep 17, 2013

👍 I love this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants