-
Notifications
You must be signed in to change notification settings - Fork 170
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
Adds a test to ensure URL paths are lower case #68
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just nits, really - looks good
pkg/frontend/frontend_test.go
Outdated
f := &frontend{} | ||
|
||
fakeRouter := mux.NewRouter() | ||
f.unauthenticatedRoutes(fakeRouter.NewRoute().Subrouter()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be up for seeing the router setup in frontend.Run pulled out into a nonexported method to avoid the duplication here, wdyt?
pkg/frontend/frontend_test.go
Outdated
|
||
// Ignore the error: it can occur when a route has no path, | ||
// but there is no way to check it here | ||
if err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: if err != nil { continue }
reduces indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a loop, but I changed it in a similar way with return nil
pkg/frontend/frontend_test.go
Outdated
if err == nil { | ||
cleanPathTemplate := varCleanupRe.ReplaceAllString(pathTemplate, "") | ||
if cleanPathTemplate != strings.ToLower(cleanPathTemplate) { | ||
t.Fatal(pathTemplate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit t.Error()
will allow someone to see all the faulty routes in one go.
ed5c33e
to
6861068
Compare
f.s = &http.Server{ | ||
Handler: middleware.Lowercase(r), | ||
Handler: middleware.Lowercase(f.setupRouter()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit for next time, might be worth getting middleware.Lowercase() in setupRouter too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jim-minter yeah, I was thinking about it, but decided to keep it here, because I wasn't sure why it wasn't in router itself initially. My guess was: a middleware added like r.Use(middleware.Lowercase)
will only be called on a route match, but we might want lowercase 404s.
Fixes #64