Skip to content

Fix legacy label regex #3972

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

Merged
merged 1 commit into from
Mar 27, 2025
Merged

Conversation

koesie10
Copy link
Member

When the legacyLabelRegex is tested multiple times against the same string (as happens most of the time, unless a user-specified label is added), it would start searching from the end of the previous match instead of from the start of the string:

“JavaScript RegExp objects are stateful when they have the global or sticky flags set (e.g., /foo/g or /foo/y). They store a lastIndex from the previous match. Using this internally, test() can be used to iterate over multiple matches in a string of text (with capture groups).”

This fixes it by resetting lastIndex before running the test method.

@Copilot Copilot AI review requested due to automatic review settings March 27, 2025 10:00
@koesie10 koesie10 requested a review from a team as a code owner March 27, 2025 10:00
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 a bug with the legacyLabelRegex by resetting its lastIndex before running test(), ensuring that the regex always starts searching from the beginning of the string.

  • Resets lastIndex on legacyLabelRegex to prevent stateful matching issues
  • Ensures legacy labels are processed correctly when used repeatedly

Tip: Copilot only keeps its highest confidence comments to reduce noise and keep you focused. Learn more

Copy link
Contributor

@starcke starcke left a comment

Choose a reason for hiding this comment

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

👍 Nice find!

@koesie10 koesie10 enabled auto-merge March 27, 2025 10:04
@koesie10 koesie10 merged commit 139226f into main Mar 27, 2025
19 checks passed
@koesie10 koesie10 deleted the koesie10/fix-legacy-history-item-labels branch March 27, 2025 10:16
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