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

Fixes Issue #48 #56

Closed
wants to merge 1 commit into from
Closed

Fixes Issue #48 #56

wants to merge 1 commit into from

Conversation

baraich
Copy link

@baraich baraich commented Jan 5, 2025

Fix: Trailing Slash Handling in Routes

This pull request addresses the issue of inconsistent handling of trailing slashes in route patterns. Previously, routes registered with a trailing slash (e.g., /issue-48/) would not match requests without the trailing slash (e.g., /issue-48), and vice versa.

Changes Made

  • Modified the _register_route function to normalize route patterns by removing any trailing slashes before registration. This ensures that routes are stored consistently without trailing slashes.

Impact

This change ensures that routes function as expected regardless of the presence or absence of a trailing slash in the request URL. Specifically:

  • Routes registered as POST /issue-48 now correctly match requests to both /issue-48 and /issue-48/.
  • Routes registered as POST /issue-48/ now also correctly match requests to both /issue-48 and /issue-48/.

This provides a more user-friendly and predictable routing experience.

Testing

  • Manually tested routes with and without trailing slashes for various HTTP methods (GET, POST, etc.).
  • Confirmed that all routes now match correctly in both scenarios.

Further Considerations

  • This approach removes trailing slashes during route registration. If there's a specific requirement to differentiate between routes with and without trailing slashes, a different approach would be needed (e.g., registering two separate routes). Shall this be the case?

This pull request resolves issue #48 .

@baraich
Copy link
Author

baraich commented Jan 5, 2025

@vinayak25
Please review the changes. Looking forward for feedback.
Thanks in advance.

@baraich
Copy link
Author

baraich commented Jan 6, 2025

@vinayak25 Leaving a notification, it's been a while. Have you gone through the changes.

@vinayak25
Copy link
Member

Hi @baraich, thanks for the PR. Give me a 1-2 days as I need to test it out once. Will review it and provide feedback soon!

@baraich
Copy link
Author

baraich commented Jan 6, 2025

@vinayak25 Thanks.

@baraich
Copy link
Author

baraich commented Jan 9, 2025

@vinayak25 Please test the changes and update. I believe everything is fine. Sorry, for saying again and again. I am preparing for my upcoming board exams (in 28 days) so I am still unable to focus on the studies as I am unable to free the brain space as it's covered with this pull request.

@baraich
Copy link
Author

baraich commented Jan 14, 2025

@vinayak25 It's been a while?

@vinayak25
Copy link
Member

Hey @baraich, i tried making some changes locally first before merging it, the performance of the HTTP router is going down by approx ~5-10%, so figuring that out how we can handle the case of trailing slash without any compromise on the performance.

@baraich baraich closed this by deleting the head repository Feb 8, 2025
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.

2 participants