go-martini / martini

Classy web framework for Go
martini.codegangsta.io
MIT License
11.63k stars 1.1k forks source link

Problems with # in route matching #429

Open DoLolitingyu opened 4 years ago

DoLolitingyu commented 4 years ago

LIke: m.Get("/hello/**", func(params martini.Params) string { return "Hello " + params["_1"] })

Enter when I visit “/hello/test#test”, It's return 404. I want to know # is treated as something else? Thank you ^-^

jerbob92 commented 1 year ago

I believe I have fixed this in my fork: https://github.com/go-martini/martini/compare/master...klippa-app:martini:master

Basically Martini does path matching on the decoded version of the URL. In that matching it handles a few characters as path delimiters, like # and /. If your path contains encoded values of these (%23 and %2F), it will show up as decoded in the matching code of Martini and it will not match them on your route.

My changes will match the route on the encoded version of the URL (using req.URL.EscapedPath()), and will then decode the path segments later on.