File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @redocly/openapi-core " : patch
3+ ---
4+
5+ Improved overall performance by skipping unnecessary JSON pointer escaping and unescaping.
Original file line number Diff line number Diff line change @@ -41,7 +41,8 @@ export class Location {
4141}
4242
4343export function unescapePointerFragment ( fragment : string ) : string {
44- const unescaped = fragment . replace ( / ~ 1 / g, '/' ) . replace ( / ~ 0 / g, '~' ) ;
44+ const unescaped =
45+ fragment . indexOf ( '~' ) === - 1 ? fragment : fragment . replaceAll ( '~1' , '/' ) . replaceAll ( '~0' , '~' ) ;
4546
4647 try {
4748 return decodeURIComponent ( unescaped ) ;
@@ -52,6 +53,8 @@ export function unescapePointerFragment(fragment: string): string {
5253
5354export function escapePointerFragment < T extends string | number > ( fragment : T ) : T {
5455 if ( typeof fragment === 'number' ) return fragment ;
56+ if ( fragment . indexOf ( '/' ) === - 1 && fragment . indexOf ( '~' ) === - 1 ) return fragment ;
57+
5558 return fragment . replaceAll ( '~' , '~0' ) . replaceAll ( '/' , '~1' ) as T ;
5659}
5760
You can’t perform that action at this time.
0 commit comments