Skip to content

Commit

Permalink
fix ts errors on urlHash encode
Browse files Browse the repository at this point in the history
  • Loading branch information
vitormv committed Jan 18, 2024
1 parent bc0ae2f commit 9180257
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/components/ExportOptions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
Export <ChevronForwardOutline size="16" />
</button>

<!-- svelte-ignore a11y-no-static-element-interactions -->
<div class="wrapper" on:mousemove|stopPropagation>
<Modal bind:showModal={isModalOpen}>
<h2 slot="header">Export & Share</h2>
Expand Down
12 changes: 8 additions & 4 deletions src/utils/urlHash.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
const ENC = {
'+': '-',
'/': '_',
} as const;
};

const DEC = {
'-': '+',
'_': '/',
'.': '=',
} as const;
};

export const encodeHash = (base64: string) => {
return base64.replace(/[+/]/g, (m: string) => ENC[m]);
return base64.replace(/[+/]/g, (match: string) =>
match in ENC ? ENC[match as keyof typeof ENC] : match,
);
};

export const decode = (safe: string) => {
return safe.replace(/[-_.]/g, (m: string) => DEC[m]);
return safe.replace(/[-_.]/g, (match: string) =>
match in DEC ? DEC[match as keyof typeof DEC] : match,
);
};

0 comments on commit 9180257

Please sign in to comment.