@redocly/theme
Version:
Shared UI components lib
35 lines (34 loc) • 1.78 kB
TypeScript
import type { Locale } from '../../core/types';
export declare function combineUrls(baseURL: string, ...relativeURLs: (string | undefined)[]): string;
export declare function withPathPrefix(url: string): string;
export declare function withoutPathPrefix(pathname: string): string;
export declare function withoutHash(url: undefined | null): undefined;
export declare function withoutHash(url: string): string;
export declare function withoutHash(url: string | undefined): string | undefined;
/**
*
* @returns url with leading and without trailing slash or empty string, e.g. '/prefix'
*/
export declare function getPathPrefix(): string;
export declare function normalizePathPrefix(prefix: string): string;
export declare function addLeadingSlash(url: string): string;
export declare function removeTrailingSlash(url: string): string;
export declare function removeLeadingSlash(url: string): string;
export declare function isPathInFolder(child: string, parent: string): boolean;
/**
* Convert Windows backslash paths to slash paths: foo\\bar ➔ foo/bar
*
* @param path
* @return slashed path
*/
export declare function slash(path: string): string;
export declare function addTrailingSlash(url: string): string;
/**
* Adds locale to pathname, or replaces current locale in pathname with a new one
* @param originalPathname - Pathname without api prefix
* @param defaultLocale - Default locale code
* @param newLocale - New locale code to apply
* @param allLocales - Array of all available locales
*/
export declare function getPathnameForLocale(originalPathname: string, defaultLocale: string, newLocale: string, allLocales: Locale[]): string;
export declare function getLocaleFromPathname(pathname: string, defaultLocale?: string, allLocales?: Locale[]): string;