npm names are parsed incorrectly (in Yarn at least)
rickity-cricket opened this issue · comments
When dealing with npmjs component names (of the format: name@version), I wanted to parse out the name. My initial thought was a naive one; "why not just split on the @ symbol?" but then I encountered something like this...
├─ @angular-devkit/core@0.0.20
Which didn't work... I recently attempted to update the yarn parsing to add production-only dependency support and, in the process, I added the following method to parse fuzzy names.
static String grabFuzzyName(String line) {
// e.g.
// ├─ whatwg-url@4.8.0 >> whatwg-url@4.8.0
// OR
// │ ├─ tr46@~0.0.3 >> tr46@~0.0.3
// [a-zA-Z\d-]+@.+[\dx]$
Pattern pattern = Pattern.compile("[ \\d.\\-a-zA-Z]+@.+")
Matcher matcher = pattern.matcher(line)
matcher.find()
String result = matcher.group(0).trim()
result
}
It seems this method was removed and deemed unnecessary, but I found this via the hub:
Each of these corresponds to a component beginning with an @ symbol
Thanks,
rickity-cricket
Can you provide some example with expected output? What should the name be from ├─ @angular-devkit/core@0.0.20
?
should it be "core"? or "angular-devkit/core"?
I was able to determine that the Hub will show the correct response if you include the first @ sign.
Ex : ├─ @angular-devkit/core@0.0.20
should result in the name being @angular-devkit/core
Please see #245
The code has been merged to fix this issue