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

Open
wants to merge 1 commit into
base: main
Choose a base branch
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
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the regex in parseRouteName to ensure that only route parameters preceded by a "/" or "..." are matched.

  • Updated regex in schema-routes.ts to use positive lookbehind for "/" or "..."
  • Enhances route parameter parsing accuracy
Comments suppressed due to low confidence (1)

src/schema-routes/schema-routes.ts:101

  • [nitpick] Consider adding an inline comment to explain the use of positive lookbehind in this regex, as this construct may be unfamiliar to some developers and can help maintainability.
      /(?<=\/|\.\.\.)({[\w[\\\]^`][-_.\w]*})|(?<=\/|\.\.\.)(:[\w[\\\]^`][-_.\w]*:?)/g,

@js2me
Copy link
Member

js2me commented Jun 25, 2025

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

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.

2 participants