Addressedtypeno test imports ittype Addressed = { readonly path: PosixPath; readonly collection: boolean };What an address is: the path and whether the address ended in a slash.
The address of a resource and the path it stands for, in both directions. An address is read one segment at a time, so that an encoded slash is never a separator, and a segment that is empty after decoding, is . or .., holds a control character, a NUL or a backslash is refused: nothing is resolved, so nothing climbs out of the root. A name that is not in the normal form of Unicode is turned into it, or refused, as the program says.
import { pathOfUrl, hrefOf } from "./href.ts";
const r = pathOfUrl(new URL("http://127.0.0.1/fleet/olympia%20one.json"), "/", "nfc");
hrefOf(r.kind === "ok" ? r.value.path : undefined, false, "/"); // "/fleet/olympia%20one.json"Addressedtypeno test imports ittype Addressed = { readonly path: PosixPath; readonly collection: boolean };What an address is: the path and whether the address ended in a slash.
AddressProblemtypeno test imports ittype AddressProblem = { readonly kind: "outside"; readonly message: string } | { readonly kind: "malformed"; readonly message: string } | { readonly kind: "unicode"; readonly message: string };Why an address is not a path of the store.
normalBasefunctionno test imports itfunction normalBase(base: string): stringThe base of an address: / or a path with no trailing slash, which the server answers below.
pathOfUrlfunctionfunction pathOfUrl(url: URL, base: string, unicode: Unicode): Result<Addressed, AddressProblem>The path an address names, below a base.
hrefOffunctionfunction hrefOf(path: PosixPath | undefined, collection: boolean, base: string): stringThe address of a path below a base; a collection ends in a slash. The root of the store is the base itself.
pathOfDestinationfunctionfunction pathOfDestination(value: string, hostOfRequest: string, base: string, unicode: Unicode): Result<Addressed, { readonly kind: "other-host"; readonly message: string; } | AddressProblem>The path a Destination names: an absolute address on the same host, or an absolute path, below the base.