@mintlify/common 1.0.1002 → 1.0.1003
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/basePaths.d.ts +2 -0
- package/dist/basePaths.js +12 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/basePaths.d.ts
CHANGED
|
@@ -5,3 +5,5 @@ export type ManagedBasePathConfig = {
|
|
|
5
5
|
export declare const MANAGED_BASE_PATHS: Map<string, ManagedBasePathConfig>;
|
|
6
6
|
export declare function isManagedBasePath(basePath: string): boolean;
|
|
7
7
|
export declare function isCustomBasePath(basePath: string): boolean;
|
|
8
|
+
export declare function normalizeBasePath(basePath: string | undefined): string;
|
|
9
|
+
export declare function stripLeadingBasePath(pathname: string, basePath: string): string;
|
package/dist/basePaths.js
CHANGED
|
@@ -23,3 +23,15 @@ export function isManagedBasePath(basePath) {
|
|
|
23
23
|
export function isCustomBasePath(basePath) {
|
|
24
24
|
return basePath.length > 0 && !MANAGED_BASE_PATHS.has(basePath);
|
|
25
25
|
}
|
|
26
|
+
export function normalizeBasePath(basePath) {
|
|
27
|
+
if (!basePath || basePath === '/')
|
|
28
|
+
return '';
|
|
29
|
+
const withLeadingSlash = basePath.startsWith('/') ? basePath : `/${basePath}`;
|
|
30
|
+
return withLeadingSlash.endsWith('/') ? withLeadingSlash.slice(0, -1) : withLeadingSlash;
|
|
31
|
+
}
|
|
32
|
+
export function stripLeadingBasePath(pathname, basePath) {
|
|
33
|
+
if (basePath && (pathname === basePath || pathname.startsWith(`${basePath}/`))) {
|
|
34
|
+
return pathname.slice(basePath.length) || '/';
|
|
35
|
+
}
|
|
36
|
+
return pathname;
|
|
37
|
+
}
|