Skip to content

fix: normalize route paths with a leading slash#591

Open
firas-yangui wants to merge 5 commits into
cot-rs:masterfrom
firas-yangui:firas-yangui/fix-leading-slash-routes
Open

fix: normalize route paths with a leading slash#591
firas-yangui wants to merge 5 commits into
cot-rs:masterfrom
firas-yangui:firas-yangui/fix-leading-slash-routes

Conversation

@firas-yangui

@firas-yangui firas-yangui commented Jun 19, 2026

Copy link
Copy Markdown

Related issue or discussion

Fixes #589

Description

Normalize non-empty route patterns in PathMatcher::new by prepending a leading slash when one is omitted.

This keeps request matching, URL reversing, and Route::url() consistent while preserving the existing behavior for empty path patterns.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Refactor / cleanup
  • Performance improvement
  • Other (describe above)

Testing

  • cargo test -p cot --all-features
  • cargo test -p cot --all-features router:: --lib
  • cargo clippy -p cot --lib --all-features -- -D warnings
  • cargo fmt --all -- --check

The repository's full all-targets Clippy command currently reports two pre-existing assertions_on_constants errors in cot/src/db/fields/chrono_fields.rs.

Checklist

  • I've read the contributing guide
  • Tests pass locally (just test-all)
  • Code passes clippy (just clippy)
  • Code is properly formatted (cargo fmt)
  • New tests added (regression test for bugs, coverage for new features)
  • Documentation (both code and site) updated (if applicable)

@github-actions github-actions Bot added the C-lib Crate: cot (main library crate) label Jun 19, 2026
@firas-yangui firas-yangui force-pushed the firas-yangui/fix-leading-slash-routes branch from 5f9f82e to 1c14d8d Compare June 19, 2026 18:54
@codecov

codecov Bot commented Jun 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
rust 90.25% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cot/src/router.rs 92.17% <100.00%> (+0.17%) ⬆️
cot/src/router/path.rs 99.65% <100.00%> (+0.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions Bot added the A-ci Area: CI (Continuous Integration) label Jun 22, 2026
@m4tx

m4tx commented Jun 22, 2026

Copy link
Copy Markdown
Member

Hey, thanks for the contribution! I will have a look at the code soon, but in the meantime please note that #593 already fixes the Miri problems, so you don't have to worry too much about them.

@firas-yangui

Copy link
Copy Markdown
Author

@m4tx Thanks for the heads-up and for taking the time to review my contribution! I’ll remove the Miri-related change so this PR stays focused on the routing issue. Looking forward to your feedback. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ci Area: CI (Continuous Integration) C-lib Crate: cot (main library crate)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Routes without leading slashes are ambiguous

2 participants