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

Shouldn't app.set("case sensitive routing") propagate to new Routers? #2564

Open
ibc opened this issue Feb 23, 2015 · 5 comments
Open

Shouldn't app.set("case sensitive routing") propagate to new Routers? #2564

ibc opened this issue Feb 23, 2015 · 5 comments
Assignees

Comments

@ibc
Copy link

ibc commented Feb 23, 2015

Just wondering if app settings such as "case sensitive routing" should be also applied in new Router instances created by the user.

Of course that would require some kind of magic in what express.Router returns (it should be a function that creates a new Router and applies the app settings unless provided by the user).

@ibc
Copy link
Author

ibc commented Feb 23, 2015

Sorry, express.Router() cannot return an instance with same settings as the app. Of course it should be done via a new method app.Router().

@dougwilson
Copy link
Contributor

There will likely be a app.createRouter(opt) in 5.0, that would create a router with the opt merged with the app's options.

@ibc
Copy link
Author

ibc commented Feb 24, 2015

Something like this works:

Application.prototype.Router = function(options) {
    options = options || {};

    if (! options.hasOwnProperty('caseSensitive')) {
        options.caseSensitive = this.enabled('case sensitive routing');
    }

    if (! options.hasOwnProperty('strict')) {
        options.strict = this.enabled('strict routing');
    }

    return new Router(options);
};

and then:

var router = app.Router(options);

@czaarek99

This comment has been minimized.

@dougwilson

This comment has been minimized.

@dougwilson dougwilson removed the 5.x label Oct 28, 2018
@dougwilson dougwilson mentioned this issue Oct 28, 2018
23 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants