1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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 };
}
const info = extractValInfo("https://esm.town/v/escalona/extractValInfo");
console.log(info);
console.debug(info);
console.warn(info)
console.error(info);
console.table(info);