Repository navigation
v0.5.1
v0.5.1 (2025-11-28)
Documentation
- docs: add task list for URL reference detection fix
Break down implementation into 4 task groups with 16 sub-tasks:
- Task Group 1: Path normalization enhancement (strip ^, $, handle /?)
- Task Group 2: Dynamic URL pattern matching (helper functions)
- Task Group 3: Integration and match function enhancement
- Task Group 4: Final verification and edge cases
Follows TDD approach with ~28-30 new tests planned. (26df666)
- docs: add spec for fixing URL reference detection false positives
Add specification for fixing false positives when detecting unreferenced
URLs. The issue occurs because regex anchors (^ and $) and optional
trailing slashes (/?) in URL patterns aren't being stripped during
normalization, causing pattern-to-href comparison to fail.
The spec covers:
- Enhanced normalize_path() to strip regex syntax
- Helper functions for detecting capture groups
- Dynamic URL matching for patterns with template variables ({{)
- Comprehensive test cases for edge cases (
1767e5e)
Fix
- fix: fix false positives on unreferenced urls
Fix false positives in URL reference detection (ae491df)
- fix: handle regex anchors and dynamic URLs in pattern matching
Fix false positives when detecting unreferenced URLs by properly handling
regex syntax in Django URL patterns.
Changes to url_matching.py:
- Enhanced normalize_path() to strip ^ and $ regex anchors
- Added support for /? optional trailing slash patterns
- Added has_capture_groups() to detect dynamic URL patterns
- Added extract_static_prefix() to get static portion before capture groups
- Added is_dynamic_href() to detect {{ template syntax in hrefs
- Modified match_href_to_pattern() to match dynamic hrefs against patterns
with capture groups by comparing static prefixes
This fixes the issue where patterns like ^my/url$ were not matching
hrefs like /my/url, and enables matching dynamic hrefs like
/user/{{ user.id }}/ against patterns like ^user/(?P<id>\d+)/$
Added 35 new tests covering:
- Regex anchor stripping (^, $, both)
- Optional trailing slash handling (/?)
- Capture group detection and prefix extraction
- Dynamic href matching
- Edge cases (multiple groups, groups at start, character classes)
All 201 tests pass with 100% coverage on url_matching.py. (28ba411)
Style
- style: apply pre-commit formatting fixes (
875cac7)