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

Tk regex #235

Draft
wants to merge 5 commits into
base: v2
Choose a base branch
from
Draft

Tk regex #235

wants to merge 5 commits into from

Conversation

ocap-kirk
Copy link

Key Features Added

  1. Support for regex pattern matching in URL paths
  2. Ability to capture named groups from regex patterns as attributes
  3. Fallback to numbered capture groups if named groups aren't present
  4. Error handling for invalid regex patterns
  5. Logging of regex match results for debugging

Step-by-Step Changes

  1. Schema Updates:

    • Added type field to MappingRuleData to distinguish between regex and traditional patterns
    • Updated validation to support regex patterns
  2. URL Comparison:

    • Modified _compare_urls to handle both traditional and regex patterns
    • Added is_regex flag to control matching behavior
    • Implemented regex pattern compilation and matching
  3. Attribute Extraction:

    • Created separate paths for regex vs traditional attribute extraction
    • Added support for named capture groups in regex patterns
    • Implemented fallback to numbered capture groups
    • Maintained backward compatibility with existing URL parameter extraction
  4. Error Handling:

    • Added try-catch blocks for regex compilation
    • Implemented logging for regex-related errors
    • Added fallback behavior for invalid patterns
  5. Logging & Debugging:

    • Added detailed logging for regex matching results
    • Included pattern and URL information in logs
    • Added debug information for troubleshooting

- Introduced regex support for mapping rules, allowing for more flexible URL matching.
- Updated `MappingRuleData` schema to include an optional `type` field for rule categorization.
- Refactored attribute extraction logic to handle both regex and traditional URL patterns.
- Improved URL comparison methods for better performance and clarity.
- Added logging for regex pattern matching and error handling.

These changes improve the robustness and flexibility of the enforcer API's routing capabilities.
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.

1 participant