Skip to content

Commit f07c6d5

Browse files
committed
Rename normalizePath to normalizePurlPath and convert to options pattern
- Rename to avoid confusion with socket-registry's normalizePath - Change callback parameter to options object: { filter } - Update call sites in normalizeNamespace and normalizeSubpath
1 parent 9778f01 commit f07c6d5

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/normalize.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@ function normalizeName(rawName: unknown): string | undefined {
1919
*/
2020
function normalizeNamespace(rawNamespace: unknown): string | undefined {
2121
return typeof rawNamespace === 'string'
22-
? normalizePath(rawNamespace, undefined)
22+
? normalizePurlPath(rawNamespace)
2323
: undefined
2424
}
2525

2626
/**
27-
* Normalize path by collapsing separators and filtering segments.
27+
* Normalize purl path component by collapsing separators and filtering segments.
2828
*/
29-
function normalizePath(
29+
function normalizePurlPath(
3030
pathname: string,
31-
callback?: ((_segment: string) => boolean) | undefined,
31+
options?: { filter?: ((_segment: string) => boolean) | undefined },
3232
): string {
33+
const { filter: callback } = options ?? {}
3334
let collapsed = ''
3435
let start = 0
3536
// Leading and trailing slashes, i.e. '/', are not significant and should be
@@ -98,7 +99,7 @@ function normalizeQualifiers(
9899
*/
99100
function normalizeSubpath(rawSubpath: unknown): string | undefined {
100101
return typeof rawSubpath === 'string'
101-
? normalizePath(rawSubpath, subpathFilter)
102+
? normalizePurlPath(rawSubpath, { filter: subpathFilter })
102103
: undefined
103104
}
104105

@@ -171,7 +172,7 @@ function subpathFilter(segment: string): boolean {
171172
export {
172173
normalizeName,
173174
normalizeNamespace,
174-
normalizePath,
175+
normalizePurlPath,
175176
normalizeQualifiers,
176177
normalizeSubpath,
177178
normalizeType,

0 commit comments

Comments
 (0)