Skip to content

resolveDocumentUrl

resolveDocumentUrl<T>(url, base): T

Defined in: packages/core/src/utils/document-base.ts:91

Resolve one URL from a map document against the document base.

Type Parameter
T
ParameterTypeDescription
urlTThe URL or path as the author wrote it.
basestring | null | undefinedThe base (any form normalizeDocumentBase accepts).

T

The URL to fetch. Unchanged without a base, for absolute and protocol-relative URLs, for #/?-only references, for non-strings, and for a root-relative path that already starts with the base.

resolveDocumentUrl("/data/x.geojson", "/my-repo/"); // "/my-repo/data/x.geojson"
resolveDocumentUrl("data/x.geojson", "/my-repo"); // "/my-repo/data/x.geojson"
resolveDocumentUrl("/my-repo/data/x.geojson", "/my-repo/"); // unchanged
resolveDocumentUrl("https://example.com/x.geojson", "/my-repo/"); // unchanged
resolveDocumentUrl("data/x.geojson", null); // unchanged