Versions

  • v0

    11/4/2024
    Open: Version
    +13
    -0

    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 };
    }
1
Next
Updated: November 4, 2024