0.1.2 • Published 6 months ago

ubborg-bundleurl-util-pmb v0.1.2

Weekly downloads
1
License
ISC
Repository
github
Last release
6 months ago

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 baseUrls. 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: If url cannot be understood as anything that could be resolved to a CJS module ID, and this option is set to anything other than undefined, 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

0.1.2

6 months ago

0.1.1

4 years ago

0.1.0

4 years ago