fix: parsing dependency path
This commit is contained in:
2 files changed
+4
-4
No files matched your search
@@ -8,13 +8,12 @@ export function isAbsolute (dependencyPath: string) {
|
||||
|
||||
export function indexOfPeersSuffix (depPath: string) {
|
||||
if (!depPath.endsWith(')')) return -1
|
||||
let open = true
|
||||
let open = 1
|
||||
for (let i = depPath.length - 2; i >= 0; i--) {
|
||||
if (depPath[i] === '(') {
|
||||
open = false
|
||||
open--
|
||||
} else if (depPath[i] === ')') {
|
||||
if (open) return -1
|
||||
open = true
|
||||
open++
|
||||
} else if (!open) {
|
||||
return i + 1
|
||||
}
|
||||
|
||||
@@ -78,5 +78,6 @@ test('depPathToFilename()', () => {
|
||||
|
||||
test('tryGetPackageId', () => {
|
||||
expect(tryGetPackageId('/foo@1.0.0(@types/babel__core@7.1.14)')).toEqual('/foo@1.0.0')
|
||||
expect(tryGetPackageId('/foo@1.0.0(@types/babel__core@7.1.14(is-odd@1.0.0))')).toEqual('/foo@1.0.0')
|
||||
expect(tryGetPackageId('/@(-.-)/foo@1.0.0(@types/babel__core@7.1.14)')).toEqual('/@(-.-)/foo@1.0.0')
|
||||
})
|
||||
Reference in new issue
Block a user