/**
 * Pattern for extracting version from URL (i.e. /v1/ or /v2/)
 */
const VERSION_PATTERN = /\/v([1-9]*)(?:\/|$)/;
const pipe = (fn, ...fns) => (...args) => fns.reduce((v, f) => f(v), fn(...args));
const getHref = (url) => url?.href ?? "";
const matchVersion = (href) => href.match(VERSION_PATTERN)?.[1] ?? "0";
const parseNumber = (s) => parseInt(s, 10) || 0;
/**
 * Retrieves the token version from a given URL
 *
 * @param {URL | undefined} url
 * @returns {number} token version if decipherable, or 0
 */
export const version = pipe(getHref, matchVersion, parseNumber);
//# sourceMappingURL=version.js.map