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

feat: optional wildcard routing in routePrefix #1499

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

matthew2564
Copy link

@matthew2564 matthew2564 commented Feb 22, 2025

Description

Introduce more complex route prefix wildcard ability

Problem

When using routing-controllers with API Gateway and custom domain names, path segments can be conditionally present. For example, a route might be accessed as both /endpoint (direct) and /custom-domain/endpoint (via custom domain). The current routing-controllers implementation doesn't support this kind of optional path segment matching.

Solution

Enhanced the routePrefix feature to support:

  1. RegExp patterns for complex matching
  2. Wildcard string patterns (*) for single segment matching
  3. Optional wildcard patterns (*?) for optional segment matching

Changes

  • Updated RoutingControllersOptions interface to support RegExp for routePrefix
  • Added convertWildcardToRegex function to handle wildcard patterns
  • Modified appendBaseRoute to process both RegExp and wildcard patterns
  • Corrected minimal amount of typing around proposed changes
  • Added additional tests for all new pattern types
  • Updated documentation with examples

Checklist

  • the pull request title describes what this PR does (not a vague title like Update index.md)
  • the pull request targets the default branch of the repository (develop)
  • the code follows the established code style of the repository
    • npm run prettier:check passes
    • npm run lint:check passes
  • tests are added for the changes I made (if any source code was modified)
  • documentation added or updated
  • I have run the project locally and verified that there are no errors

Fixes

fixes #[issue number], fixes #[issue number]

@matthew2564 matthew2564 marked this pull request as ready for review February 24, 2025 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant