Public
Script
Forked from pomdtr/extractValInfo
July 25, 2024
1
2
3
4
5
6
7
8
9
10
11
12
13
export function extractValInfo(url: string | URL) {
const { pathname, search } = new URL(url);
const [author, filename] = pathname.split("/").slice(-2);
const [name] = filename.split(".");
const version = new URLSearchParams(search).get("v");
const slug = `${author}/${name}`;
const htmlUrl = `https://val.town/v/${author}/${name}`;
const rawUrl = `https://esm.town/v/${author}/${name}`;
const embedUrl = `https://val.town/embed/${author}/${name}`;
const httpEndpoint = `https://${author}-${name}.web.val.run`;
return { author, name, version, slug, htmlUrl, rawUrl, httpEndpoint, embedUrl };
}
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!
July 25, 2024