@@ -324,7 +324,7 @@ class PackageURL {
324324 const afterColon = purlStr . slice ( colonIndex + 1 )
325325 const trimmedAfterColon = trimLeadingSlashes ( afterColon )
326326 url = new URL ( `${ beforeColon } :${ trimmedAfterColon } ` )
327- /* c8 ignore next 4 -- V8 coverage sees multiple branch paths in ternary that can't all be tested. */ maybeUrlWithAuth =
327+ /* c8 ignore next 4 -- V8 coverage sees multiple branch paths in ternary that can't all be tested. */ maybeUrlWithAuth =
328328 afterColon . length === trimmedAfterColon . length
329329 ? url
330330 : new URL ( purlStr )
@@ -335,7 +335,9 @@ class PackageURL {
335335 }
336336 }
337337 // The scheme is a constant with the value "pkg".
338- /* c8 ignore next -- Tested: colonIndex === -1 (url undefined) case, but V8 can't see both branches. */ if ( url ?. protocol !== 'pkg:' ) {
338+ /* c8 ignore next -- Tested: colonIndex === -1 (url undefined) case, but V8 can't see both branches. */ if (
339+ url ?. protocol !== 'pkg:'
340+ ) {
339341 throw new PurlError ( 'missing required "pkg" scheme component' )
340342 /* c8 ignore next -- Unreachable code after throw. */
341343 }
@@ -361,12 +363,11 @@ class PackageURL {
361363 let rawVersion : string | undefined
362364 // Both branches of this ternary are tested, but V8 reports phantom branch combinations
363365 /* c8 ignore start -- npm vs non-npm path logic both tested but V8 sees extra branches. */
366+ // Deviate from the specification to handle a special npm purl type case for
367+ 364368 let atSignIndex =
365369 rawType === 'npm'
366- // Deviate from the specification to handle a special npm purl type case for
367- ?
368- 369- pathname . indexOf ( '@' , firstSlashIndex + 2 )
370+ ? pathname . indexOf ( '@' , firstSlashIndex + 2 )
370371 : pathname . lastIndexOf ( '@' )
371372 /* c8 ignore stop */
372373 // When a forward slash ('/') is directly preceding an '@' symbol,
@@ -418,7 +419,10 @@ class PackageURL {
418419 const value = decodePurlComponent ( 'qualifiers' , pairs . at ( 1 ) ?? '' )
419420 // Use URLSearchParams#append to preserve plus signs.
420421 // https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams#preserving_plus_signs
421- /* c8 ignore next -- URLSearchParams.append has internal V8 branches we can't control. */ searchParams . append ( pairs [ 0 ] ! , value )
422+ /* c8 ignore next -- URLSearchParams.append has internal V8 branches we can't control. */ searchParams . append (
423+ pairs [ 0 ] ! ,
424+ value ,
425+ )
422426 }
423427 // Split the remainder once from right on '?'.
424428 rawQualifiers = searchParams
0 commit comments