Skip to content

Commit b5643f0

Browse files
committed
chore: test potential performance improvement
1 parent 92eb22d commit b5643f0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

packages/core/src/ref-utils.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class Location {
4141
}
4242

4343
export function unescapePointerFragment(fragment: string): string {
44-
return decodeURIComponent(fragment).replaceAll('~1', '/').replaceAll('~0', '~');
44+
return decodeURIComponent(fragment).replace(/~1/g, '/').replace(/~0/g, '~');
4545
}
4646

4747
export function escapePointerFragment<T extends string | number>(fragment: T): T {
@@ -52,12 +52,12 @@ export function escapePointerFragment<T extends string | number>(fragment: T): T
5252
// RFC 6901: https://datatracker.ietf.org/doc/html/rfc6901#section-6
5353
function encodeURIFragmentIdentifier(fragment: string): string {
5454
return fragment
55-
.replaceAll('%', '%25')
56-
.replaceAll('^', '%5E')
57-
.replaceAll('|', '%7C')
58-
.replaceAll('\\\\', '%5C')
59-
.replaceAll('\\', '%22')
60-
.replaceAll(' ', '%20');
55+
.replace(/%/g, '%25')
56+
.replace(/^/g, '%5E')
57+
.replace(/|/g, '%7C')
58+
.replace(/\\\\/g, '%5C')
59+
.replace(/\\/g, '%22')
60+
.replace(/ /g, '%20');
6161
}
6262

6363
export function parseRef(ref: string): { uri: string | null; pointer: string[] } {

0 commit comments

Comments
 (0)