add support for aliases in the npm cli detector#1680
Open
dterrybd wants to merge 2 commits intodev/dterry/IDETECT-4965-npm-alias-featurefrom
Open
add support for aliases in the npm cli detector#1680dterrybd wants to merge 2 commits intodev/dterry/IDETECT-4965-npm-alias-featurefrom
dterrybd wants to merge 2 commits intodev/dterry/IDETECT-4965-npm-alias-featurefrom
Conversation
zahidblackduck
approved these changes
Mar 12, 2026
| * @return true if the value is an npm alias (starts with "npm:") | ||
| */ | ||
| public static boolean isNpmAlias(String value) { | ||
| return value != null && value.startsWith("npm:"); |
Collaborator
There was a problem hiding this comment.
Seems like we could use static final constants here as npm: prefix is used in multiple places. Also for other constant symbols (e.g., @, / etc.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR builds upon the previous npm package json detector changes.
It extracts existing code to a new NpmAliasParser that can be used by both the CLI and the package JSON detectors.
It then alters the NpmCliParser to build a map of alias names to actual package names. This is called once at the start of parsing for efficiency.
When dependencies are about to be made and added to the graph, this aliasMapping structure is used to get the true package name. From here the previous code paths are leveraged.