UNPKG

fumadocs-core

Version:

The React.js library for building a documentation website

15 lines (14 loc) • 430 B
//#region src/utils/normalize-url.tsx /** * normalize URL into the Fumadocs standard form (`/slug-1/slug-2`). * * This includes URLs with trailing slashes. */ function normalizeUrl(url) { if (url.startsWith("http://") || url.startsWith("https://")) return url; if (!url.startsWith("/")) url = "/" + url; if (url.length > 1 && url.endsWith("/")) url = url.slice(0, -1); return url; } //#endregion export { normalizeUrl as t };