Skip to content

Commit

Permalink
chore: fix site
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Mar 24, 2024
1 parent fdf71e5 commit 32984e2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions docs/.vitepress/theme/components/state/deserialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ export function deserializeState(serializedString) {
}

try {
// For backward compatibility, it can address non-compressed data.
const compressed = !serializedString.startsWith("eyJj");
const decodedText = window.atob(serializedString);
const jsonText = compressed
? pako.inflate(decodedText, { to: "string" })
: decodedText;
const jsonText = pako.inflate(
Uint8Array.from(decodedText, (c) => c.charCodeAt(0)),
{ to: "string" },
);
const json = JSON.parse(jsonText);

if (typeof json === "object" && json != null) {
Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/theme/components/state/serialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function serializeState(state) {
rules: state.rules ? getEnabledRules(state.rules) : undefined,
};
const jsonString = JSON.stringify(saveData);
const compressedString = pako.deflate(jsonString, { to: "string" });
const compressedString = String.fromCharCode(...pako.deflate(jsonString));
const base64 =
(typeof window !== "undefined" && window.btoa(compressedString)) ||
compressedString;
Expand Down

0 comments on commit 32984e2

Please sign in to comment.