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

Case Insensitive Routing #83

Closed
Russman12 opened this issue Sep 24, 2021 · 4 comments
Closed

Case Insensitive Routing #83

Russman12 opened this issue Sep 24, 2021 · 4 comments

Comments

@Russman12
Copy link

We would like the ability to make case insensitive route calls. In other words, if we have set up a route to /my/route we would like a call to /MY/ROUTE to hit that route. I could not find any documentation explaining how to do this in the current project. Is this already possible? If so, how? If not, would it be possible to add it as a feature? I'm happy to help develop it, but not sure exactly how it ought to be implemented.

@dimfeld
Copy link
Owner

dimfeld commented Sep 24, 2021

This isn't implemented right now but I'm happy to take a PR for it.

Aside from tests and docs, I think these 3 changes are needed:

  1. Add a CaseInsensitive boolean option to the TreeMux object.
  2. If it's true, then convert path to lowercase at
    trailingSlash := path[pathLen-1] == '/' && pathLen > 1
    and probably unescapedPath later where it's actually used.
  3. If it's true, convert thePath to lowercase at
    node := g.mux.root.addPath(thePath[1:], nil, false)

I think that should do it!

@Russman12
Copy link
Author

Thanks for the quick response. I'll make a pull request when I have some free time.

@Russman12
Copy link
Author

I have submitted a PR: #84

@dimfeld
Copy link
Owner

dimfeld commented Oct 7, 2021

Closed by #84

@dimfeld dimfeld closed this as completed Oct 7, 2021
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

2 participants