Skip to content

Commit 34f3d2a

Browse files
committed
Removing URL params
1 parent 9e30a79 commit 34f3d2a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/lib/layout/StatsView.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import type { ProcessedStats } from "$lib/stats";
1010
import { STATS_INTROS, STATS_OUTROS } from "$lib/strings";
1111
import { randChoice } from "$lib/util/array";
12+
import { removeUrlParams } from "$lib/util/string";
1213
1314
export let stats: ProcessedStats;
1415
export let api: SongAPI;
@@ -17,6 +18,7 @@
1718
1819
const introText = randChoice(STATS_INTROS);
1920
const outroText = randChoice(STATS_OUTROS);
21+
const shareURL = removeUrlParams(window.location.href) + "?s=" + stats.toBase64();
2022
2123
let currentPage = 0;
2224
const pageCount = 5;
@@ -99,7 +101,7 @@
99101

100102
<div style="text-align: center; margin: 0 auto; max-width: 500px">
101103
<p>Share your stats!</p>
102-
<CopyField value={window.location.href + "?s=" + stats.toBase64()} />
104+
<CopyField value={shareURL} />
103105
<LinkButton text="Home page" onClick={onClose} highlight />
104106
</div>
105107
{/snippet}

src/lib/util/string.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2+
export function removeUrlParams(url: string): string {
3+
const split = url.split("?");
4+
5+
return split[0];
6+
}
7+
18
/* base64 */
29
export function base64EncodeBytes(bytes: Uint8Array): string {
310
const binStr = Array.from(bytes, (byte) => String.fromCodePoint(byte)).join("");

0 commit comments

Comments
 (0)