Skip to content

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/").

ParameterTypeDescription
basestring | null | undefined"/my-repo", "/my-repo/", "my-repo", "/", an absolute URL, or nothing.

string | null

The normalized base, or null when there is none (empty or whitespace-only). Query and fragment are dropped.

normalizeDocumentBase("/my-repo"); // "/my-repo/"
normalizeDocumentBase("my-repo/"); // "/my-repo/"
normalizeDocumentBase("/"); // "/"
normalizeDocumentBase(""); // null