SaturnFramework / Saturn

Opinionated, web development framework for F# which implements the server-side, functional MVC pattern
https://saturnframework.org
MIT License
714 stars 108 forks source link

URLs are case-sensitive #145

Closed faabergr closed 5 years ago

faabergr commented 5 years ago

I followed the steps in the How to start in 60 seconds and I noticed that the router URL matching is case sensitive. Casing books with a capital B gets me a 404 error. I'm happy to try to make a PR if someone can point me to the right place in the code. :)

talbottmike commented 5 years ago

If you'd like to submit a PR for the docs, the page you are looking for is here. https://github.com/SaturnFramework/docs/blob/master/docs/guides/how-to-start.md

If you're looking to submit a PR to change the case sensitivity behaviour of Saturn, I don't see any references to case sensitivity in Saturn routing. Not sure if this was intentional or just not considered.

Just in case you're not aware, Saturn is an abstraction over Giraffe.

The Giraffe router module has separate case sensitive and case insensitive functions. Here's an example. https://github.com/giraffe-fsharp/Giraffe/blob/4b0e5e88f90bf4b3e2443d9d7ed6a36a07637cca/src/Giraffe/Routing.fs#L76-L110

jeremyabbott commented 5 years ago

@faabergr I talked about this with @Krzysztof-Cieslak a couple of weeks ago. We discussed potentially adding a custom operation to Pipelines to convert request paths to lower case. That way it would be opt in. It would effectively prepend an HttpHandler to the pipeline to do something like

ctx.Request.Path <- PathString(ctx.Request.Path.Value.ToLower())
dustinmoris commented 5 years ago

It would effectively prepend an HttpHandler to the pipeline to do something like..

You have to be careful though, because if you make the entire path lowercase by default then you might break user input which is embedded in the URL as route arguments. For example a base64 encoded string or a secret string in the route, etc.

Krzysztof-Cieslak commented 5 years ago

Potential fix (or rather new feature) in https://github.com/SaturnFramework/Saturn/pull/156