File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed
docs/.vitepress/theme/components/state Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -16,12 +16,12 @@ export function deserializeState(serializedString) {
1616 }
1717
1818 try {
19- // For backward compatibility, it can address non-compressed data.
20- const compressed = ! serializedString . startsWith ( "eyJj" ) ;
21- const decodedText = window . atob ( serializedString ) ;
22- const jsonText = compressed
23- ? pako . inflate ( decodedText , { to : "string" } )
24- : decodedText ;
19+ const compressedString = window . atob ( serializedString ) ;
20+ const uint8Arr = pako . inflate (
21+ Uint8Array . from ( compressedString , ( c ) => c . charCodeAt ( 0 ) ) ,
22+ ) ;
23+
24+ const jsonText = new TextDecoder ( ) . decode ( uint8Arr ) ;
2525 const json = JSON . parse ( jsonText ) ;
2626
2727 if ( typeof json === "object" && json != null ) {
Original file line number Diff line number Diff line change @@ -25,7 +25,9 @@ export function serializeState(state) {
2525 rules : state . rules ? getEnabledRules ( state . rules ) : undefined ,
2626 } ;
2727 const jsonString = JSON . stringify ( saveData ) ;
28- const compressedString = pako . deflate ( jsonString , { to : "string" } ) ;
28+
29+ const uint8Arr = new TextEncoder ( ) . encode ( jsonString ) ;
30+ const compressedString = String . fromCharCode ( ...pako . deflate ( uint8Arr ) ) ;
2931 const base64 =
3032 ( typeof window !== "undefined" && window . btoa ( compressedString ) ) ||
3133 compressedString ;
You can’t perform that action at this time.
0 commit comments