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

Router match with and without trailing slash? #590

Open
jondashkyle opened this issue Oct 23, 2017 · 6 comments
Open

Router match with and without trailing slash? #590

jondashkyle opened this issue Oct 23, 2017 · 6 comments

Comments

@jondashkyle
Copy link

Hey all, ran into a funny one tonight. What are thoughts on matching the router against routes both with and without trailing slashes? For instance, if I add a route like this:

app.route('/about, view)

… should I expect it to work when navigating to both /about and /about/? Currently the latter does not. Open to thoughts! I think it’d be useful.

@yoshuawuyts
Copy link
Member

yoshuawuyts commented Oct 23, 2017 via email

@tornqvist
Copy link
Member

Great to hear that you're working on a new version of the router, @yoshuawuyts. I was just about to make a PR implementing path-to-regexp (which has an option for strict mode to ignore trailing slash or not), though my motivation was to get optional parameters. Maybe that would be a candidate for the rewrite?

@yoshuawuyts
Copy link
Member

@tornqvist a PR to to nanorouter would be great!path-to-regexp is too much code, and not JavaScript either, so it wouldn't be a good fit for our poject.

@tornqvist
Copy link
Member

What do you mean it’s not JavaScript? The size concern does make sense though, I’ll see what I can come up with.

@yoshuawuyts
Copy link
Member

@tornqvist oh, it's TypeScript if I read it right. If possible it'd be nice to keep all our deps in basic JS without compile steps; that way everyone can read it, and everyone can tweak it. Does that make sense?

@tornqvist
Copy link
Member

Def makes sense but the main export is plain old ES4 (with super expressive JSDoc). Though their tests are in TypeScript and they have some type definition files in their repo. But so does choo. Either way, I tend to agree that almost 400 LOC just to get some regex magic in routes can be considered overkill for a 4kb framework.

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

No branches or pull requests

3 participants