File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 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 ;
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 ;
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 }
Original file line number Diff line number Diff line change 1+
2+ export function removeUrlParams ( url : string ) : string {
3+ const split = url . split ( "?" ) ;
4+
5+ return split [ 0 ] ;
6+ }
7+
18/* base64 */
29export function base64EncodeBytes ( bytes : Uint8Array ) : string {
310 const binStr = Array . from ( bytes , ( byte ) => String . fromCodePoint ( byte ) ) . join ( "" ) ;
You can’t perform that action at this time.
0 commit comments