Skip to content

Fix auto import path mapping when first pattern fails #54868

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
Jul 3, 2023
Merged

Conversation

andrewbranch
Copy link
Member

Fixes #54324

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Jul 3, 2023
@@ -775,7 +775,9 @@
validateEnding({ ending, value })
) {
const matchedStar = value.substring(prefix.length, value.length - suffix.length);
return pathIsRelative(matchedStar) ? undefined : key.replace("*", matchedStar);
if (!pathIsRelative(matchedStar)) {
return key.replace("*", matchedStar);

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding

This replaces only the first occurrence of "*".
Copy link
Member

Choose a reason for hiding this comment

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

=(

Edit: Is there an unambiguous way to replace only once so codeql won't complain? Probably not, that would be too easy.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, you can use a global regex, but I don’t want to allocate an object when a string literal will do.

@andrewbranch andrewbranch requested a review from sandersn July 3, 2023 18:15
@@ -775,7 +775,9 @@
validateEnding({ ending, value })
) {
const matchedStar = value.substring(prefix.length, value.length - suffix.length);
return pathIsRelative(matchedStar) ? undefined : key.replace("*", matchedStar);
if (!pathIsRelative(matchedStar)) {
return key.replace("*", matchedStar);
Copy link
Member

Choose a reason for hiding this comment

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

=(

Edit: Is there an unambiguous way to replace only once so codeql won't complain? Probably not, that would be too easy.

@andrewbranch andrewbranch merged commit f4d372a into main Jul 3, 2023
@andrewbranch andrewbranch deleted the bug/54324 branch July 3, 2023 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto import does not pick up shortest path despite correct setting (JavaScript project with jsconfig.json)
3 participants