ubborg-bundleurl-util-pmb
v0.1.2
Published
Convert and resolve ubborg bundle URLs.
Downloads
7
Readme
ubborg-bundleurl-util-pmb
Convert and resolve ubborg bundle URLs.
API
This module exports an object that holds these functions and properties:
.shorten(url)
Return a less cluttered, more human-readable representation. This works on a purely theoretical basis, with no actual system state lookups. Thus, it will not try to read meaning into URLs, e.g. will not try to guess a "simpler" more symbolic URL just because it would happen to point to the same target given current system state.
.href(baseUrl[, dest])
Returns the full target URL, deciphering the meaning of
potentially-relative dest
URLs and potentially .shorten()
ed baseUrl
s.
If dest
is omitted or false-y, returns the full ("un-shorten()
-ed")
representation of baseUrl
.
.toModuleId(url[, opt])
Return a CommonJS-style module identifiers suitable for dynamic import.
This works on a purely theoretical basis, with no actual file system lookups.
Thus, if the url
assumes ubborg-specific features like slashable import,
the resulting module identifiers may require a suitably extended dynamic
import facility.
opt
is an optional options object that supports these optional keys:
ifUnsupported
: Ifurl
cannot be understood as anything that could be resolved to a CJS module ID, and this option is set to anything other thanundefined
, the option value is returned, rather than an Error thrown.
.cwdUrl
String with a URL that represents the current working directory.
Usage
see test/usage.mjs.
Known issues
- Needs more/better tests and docs.
License
ISC