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

Make CleanPath middleware work with other routers #786

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

romain-tadiello
Copy link

The rctx is not checked and could be nil if the function isn't used with a chi.Router.
It ends up in a panic.

Additional point: the cleaning only happens in the rctx.RoutePath is an empty string. If a function like GetHead is called before it won't clean the path.

}

rctx.RoutePath = path.Clean(routePath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wont it panic on this line if rctx is nil..? and this PR changes the logic of the method as well, calling path.Clean() more often then previously

@gangelop
Copy link

gangelop commented Mar 8, 2024

in #787 @romain-tadiello says

Additional point: the cleaning only happens in the rctx.RoutePath is an empty string. If a function like GetHead is called before it won't clean the path.

I'm not sure but this might be relevant to why he moved the path.Clean() out of the conditional.
Apologies if that's not relevant. I literally just started using chi today.

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

Successfully merging this pull request may close these issues.

None yet

3 participants