Skip to content

Commit fbe3bc4

Browse files
committed
slight ref
1 parent 2f6c8e9 commit fbe3bc4

1 file changed

Lines changed: 2 additions & 10 deletions

File tree

packages/core/src/utils/url.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export function getSanitizedUrlStringFromUrlObject(url: URLObject): string {
134134
* unconditionally — setting an attribute to `undefined` is a no-op.
135135
*/
136136
export function getUrlQuery(query: string | undefined): string | undefined {
137-
return stripUrlPartPrefix(query, '?');
137+
return query?.replace(/^\?/, '') || undefined;
138138
}
139139

140140
/**
@@ -145,15 +145,7 @@ export function getUrlQuery(query: string | undefined): string | undefined {
145145
* unconditionally — setting an attribute to `undefined` is a no-op.
146146
*/
147147
export function getUrlFragment(fragment: string | undefined): string | undefined {
148-
return stripUrlPartPrefix(fragment, '#');
149-
}
150-
151-
function stripUrlPartPrefix(value: string | undefined, prefix: '?' | '#'): string | undefined {
152-
if (!value) {
153-
return undefined;
154-
}
155-
156-
return (value.startsWith(prefix) ? value.slice(1) : value) || undefined;
148+
return fragment?.replace(/^\#/, '') || undefined;
157149
}
158150

159151
type PartialRequest = {

0 commit comments

Comments
 (0)