Skip to content

fix regex related parsing route name #1284

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

Closed
wants to merge 1 commit into from

Conversation

ghg070
Copy link

@ghg070 ghg070 commented Jun 12, 2025

We used swagger-typescript-api to parse and encountered the same issue as this developer (#532). Is it possible to modify the regex in parseRouteName to ensure that there is always a "/" or "..." at the beginning before treating it as a parameter?

Copy link

changeset-bot bot commented Jun 12, 2025

⚠️ No Changeset found

Latest commit: cb2ec8b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ghg070 ghg070 force-pushed the feature/colon-issue branch from a0516dc to 1513e43 Compare June 12, 2025 11:01
@ghg070 ghg070 closed this Jun 12, 2025
@ghg070 ghg070 reopened this Jun 13, 2025
@ghg070 ghg070 force-pushed the feature/colon-issue branch from 1513e43 to cb2ec8b Compare June 13, 2025 02:14
@ghg070 ghg070 changed the title fix regex when parsing route name fix regex related parsing route name Jun 13, 2025
@js2me js2me requested a review from smorimoto June 24, 2025 12:50
@smorimoto smorimoto requested a review from Copilot June 24, 2025 15:50
Copilot

This comment was marked as duplicate.

@js2me
Copy link
Member

js2me commented Jun 25, 2025

Hello @ghg070
Please add some unit tests based on your changes

@smorimoto
Copy link
Collaborator

bugbot run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bugbot free trial expires on September 2, 2025
Learn more in the Cursor dashboard.

@@ -98,7 +98,7 @@ export class SchemaRoutes {

// TODO forbid leading symbols [\]^` in a major release (allowed yet for backwards compatibility)
const pathParamMatches = (routeName || "").match(
/({[\w[\\\]^`][-_.\w]*})|(:[\w[\\\]^`][-_.\w]*:?)/g,
/(?<=\/|\.\.\.)({[\w[\\\]^`][-_.\w]*})|(?<=\/|\.\.\.)(:[\w[\\\]^`][-_.\w]*:?)/g,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Regex Lookbehind Compatibility Issue

The regex in parseRouteName now uses positive lookbehind assertions. As an ES2018 feature, these cause a SyntaxError in older JavaScript environments (e.g., Safari <16.4, Firefox <78, Node.js <8.10), which breaks route parsing functionality.

Fix in Cursor Fix in Web

@ghg070 ghg070 closed this Aug 22, 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.

3 participants