a description of a parsed jsr/npm package, that somewhat resembles the properties of regular URL.

interface PackagePseudoUrl {
    href: string;
    protocol: "npm:" | "jsr:";
    scope?: string;
    pkg: string;
    version?: string;
    pathname: string;
    host: string;
}

Properties

href: string

the full package string, compatible to use with the URL constructor.

examples:

  • jsr:/@scope/package@version/pathname
  • jsr:/@scope/package
  • npm:/package@version/pathname
  • npm:/@scope/package@version
protocol: "npm:" | "jsr:"
scope?: string

optional scope name.

pkg: string

name of the package. the reason why we call it "pkg" instead of "package" is because "package" is a reserved word in javascript.

version?: string

optional version string of the package.

pathname: string

the pathname of the subpath that is being accessed within the package. this will always begin with a leading slash ("/"), even if there is no subpath being accessed.

host: string

the host contains the full information about the package's string. that is, it has the optional scope information, the package name information, and the optional version information.