Skip to content

Replace final character in string, as opposted to first instance of * #2418

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

Conversation

gingerbenw
Copy link
Member

Goal

Update node export resolver code to fix code scanning alert 125

@gingerbenw gingerbenw requested a review from Copilot April 14, 2025 10:23
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.

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

jest/node-exports-resolver.js:147

  • Using /$/ matches the end-of-string position (a zero-width match) rather than the final character. If the goal is to replace the last character of the string, consider using /.$/ instead.
+                  /\$/, submoduleName.slice(exportKey.length - 1)

@gingerbenw gingerbenw force-pushed the gingerbenw/fix-ncomplete-string-escaping branch from 5de08d2 to b4658e7 Compare April 14, 2025 10:24
Copy link

github-actions bot commented Apr 14, 2025

@bugsnag/browser bundle size diff

Minified Minfied + Gzipped
Before 56.43 kB 17.15 kB
After 56.43 kB 17.15 kB
± No change No change

code coverage diff

<temporarily disabled>

Generated by 🚫 dangerJS against b4658e7

@gingerbenw gingerbenw requested a review from Copilot April 14, 2025 10:36
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.

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

jest/node-exports-resolver.js:146

  • The replacement regex /.$/ replaces the last character regardless of its value, which may lead to unintended behavior if exportValue does not actually end with ''. Consider adding a check to ensure exportValue ends with '' before performing the replacement.
exportValue.replace(/.$/, submoduleName.slice(exportKey.length - 1))

@gingerbenw gingerbenw marked this pull request as ready for review April 14, 2025 11:09
@gingerbenw gingerbenw closed this Apr 28, 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.

1 participant