@@ -34,31 +34,31 @@ function normalizePurlPath(
3434 let collapsed = ''
3535 let start = 0
3636 // Leading and trailing slashes, i.e. '/', are not significant and should be
37- // stripped in the canonical form.
37+ // stripped in the canonical form
3838 while ( pathname . charCodeAt ( start ) === 47 /*'/'*/ ) {
3939 start += 1
4040 }
4141 let nextIndex = pathname . indexOf ( '/' , start )
4242 if ( nextIndex === - 1 ) {
43- // No slashes found - return trimmed pathname.
43+ // No slashes found - return trimmed pathname
4444 return pathname . slice ( start )
4545 }
4646 // Discard any empty string segments by collapsing repeated segment
47- // separator slashes, i.e. '/'.
47+ // separator slashes, i.e. '/'
4848 while ( nextIndex !== - 1 ) {
4949 const segment = pathname . slice ( start , nextIndex )
5050 if ( callback === undefined || callback ( segment ) ) {
51- // Add segment with separator if not first segment.
51+ // Add segment with separator if not first segment
5252 collapsed = collapsed + ( collapsed . length === 0 ? '' : '/' ) + segment
5353 }
54- // Skip to next segment, consuming multiple consecutive slashes.
54+ // Skip to next segment, consuming multiple consecutive slashes
5555 start = nextIndex + 1
5656 while ( pathname . charCodeAt ( start ) === 47 ) {
5757 start += 1
5858 }
5959 nextIndex = pathname . indexOf ( '/' , start )
6060 }
61- // Handle last segment after final slash.
61+ // Handle last segment after final slash
6262 const lastSegment = pathname . slice ( start )
6363 if (
6464 lastSegment . length !== 0 &&
@@ -76,19 +76,19 @@ function normalizeQualifiers(
7676 rawQualifiers : unknown ,
7777) : Record < string , string > | undefined {
7878 let qualifiers : Record < string , string > | undefined
79- // Use for-of to work with entries iterators.
79+ // Use for-of to work with entries iterators
8080 for ( const { 0 : key , 1 : value } of qualifiersToEntries ( rawQualifiers ) ) {
8181 const strValue = typeof value === 'string' ? value : String ( value )
8282 const trimmed = strValue . trim ( )
8383 // A key=value pair with an empty value is the same as no key/value
84- // at all for this key.
84+ // at all for this key
8585 if ( trimmed . length === 0 ) {
8686 continue
8787 }
8888 if ( qualifiers === undefined ) {
8989 qualifiers = Object . create ( null ) as Record < string , string >
9090 }
91- // A key is case insensitive. The canonical form is lowercase.
91+ // A key is case insensitive. The canonical form is lowercase
9292 qualifiers [ key . toLowerCase ( ) ] = trimmed
9393 }
9494 return qualifiers
@@ -107,8 +107,8 @@ function normalizeSubpath(rawSubpath: unknown): string | undefined {
107107 * Normalize package type to lowercase.
108108 */
109109function normalizeType ( rawType : unknown ) : string | undefined {
110- // The type must NOT be percent-encoded.
111- // The type is case insensitive. The canonical form is lowercase.
110+ // The type must NOT be percent-encoded
111+ // The type is case insensitive. The canonical form is lowercase
112112 return typeof rawType === 'string' ? rawType . trim ( ) . toLowerCase ( ) : undefined
113113}
114114
@@ -119,9 +119,9 @@ function normalizeVersion(rawVersion: unknown): string | undefined {
119119 return typeof rawVersion === 'string' ? rawVersion . trim ( ) : undefined
120120}
121121
122- // IMPORTANT: Do not use destructuring here - use direct assignment instead.
122+ // IMPORTANT: Do not use destructuring here - use direct assignment instead
123123// tsgo has a bug that incorrectly transpiles destructured exports, resulting in
124- // `exports.ReflectApply = void 0;` which causes runtime errors.
124+ // `exports.ReflectApply = void 0;` which causes runtime errors
125125// See: https://github.com/SocketDev/socket-packageurl-js/issues/3
126126const ReflectApply = Reflect . apply
127127
@@ -132,7 +132,7 @@ function qualifiersToEntries(
132132 rawQualifiers : unknown ,
133133) : Iterable < [ string , string ] > {
134134 if ( isObject ( rawQualifiers ) ) {
135- // URLSearchParams instances have an "entries" method that returns an iterator.
135+ // URLSearchParams instances have an "entries" method that returns an iterator
136136 const rawQualifiersObj = rawQualifiers as QualifiersObject | URLSearchParams
137137 const entriesProperty = ( rawQualifiersObj as QualifiersObject ) [ 'entries' ]
138138 return typeof entriesProperty === 'function'
0 commit comments