Public
Script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { base64 as b64 } from "npm:multiformats/bases/base64";
export function newValURL(code?: string, base64 = true) {
const url = new URL("https://www.val.town/new");
if (!code) {
return url;
}
if (!base64) {
url.searchParams.set("code", code);
return url;
}
// @see: https://www.val.town/v/easrng/playground?v=343#L703-704
const bytes = new TextEncoder().encode(code);
url.searchParams.set("code64", b64.baseEncode(bytes));
return url;
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
March 31, 2024