normalizeDocumentBase
normalizeDocumentBase(
base):string|null
Defined in: packages/core/src/utils/document-base.ts:63
Normalize a base value to the form resolveDocumentUrl joins with:
a path that starts and ends with / ("/my-repo/"), or an absolute URL
ending in / ("https://cdn.example.com/site/").
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
base | string | null | undefined | "/my-repo", "/my-repo/", "my-repo", "/", an absolute URL, or nothing. |
Returns
Section titled “Returns”string | null
The normalized base, or null when there is none (empty or
whitespace-only). Query and fragment are dropped.
Example
Section titled “Example”normalizeDocumentBase("/my-repo"); // "/my-repo/"normalizeDocumentBase("my-repo/"); // "/my-repo/"normalizeDocumentBase("/"); // "/"normalizeDocumentBase(""); // null