Files
SnowLuma/.pnpm-store/v11/files/e2/fe61075111f9a334ef266873e27bca6ad6aba504a55630f683aa88ae04859cc5b041d71eebf0d335f33c30af339f988a6a33e556f287bdaea8f52387040238
T
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

57 lines
2.4 KiB
Plaintext

import { LRUCache } from './lru-cache.js';
/** Join path segments, cleaning duplicate slashes between parts. */
export declare function joinPaths(paths: Array<string | undefined>): string;
/** Remove repeated slashes from a path string. */
export declare function cleanPath(path: string): string;
/** Trim leading slashes (except preserving root '/'). */
export declare function trimPathLeft(path: string): string;
/** Trim trailing slashes (except preserving root '/'). */
export declare function trimPathRight(path: string): string;
/** Trim both leading and trailing slashes. */
export declare function trimPath(path: string): string;
/** Remove a trailing slash from value when appropriate for comparisons. */
export declare function removeTrailingSlash(value: string, basepath: string): string;
/**
* Compare two pathnames for exact equality after normalizing trailing slashes
* relative to the provided `basepath`.
*/
export declare function exactPathTest(pathName1: string, pathName2: string, basepath: string): boolean;
interface ResolvePathOptions {
base: string;
to: string;
trailingSlash?: 'always' | 'never' | 'preserve';
cache?: LRUCache<string, string>;
}
/**
* Resolve a destination path against a base, honoring trailing-slash policy
* and supporting relative segments (`.`/`..`) and absolute `to` values.
*/
export declare function resolvePath({ base, to, trailingSlash, cache, }: ResolvePathOptions): string;
/**
* Create a pre-compiled decode config from allowed characters.
* This should be called once at router initialization.
*/
export declare function compileDecodeCharMap(pathParamsAllowedCharacters: ReadonlyArray<string>): (encoded: string) => string;
interface InterpolatePathOptions {
path?: string;
params: Record<string, unknown>;
/**
* A function that decodes a path parameter value.
* Obtained from `compileDecodeCharMap(pathParamsAllowedCharacters)`.
*/
decoder?: (encoded: string) => string;
}
type InterPolatePathResult = {
interpolatedPath: string;
usedParams: Record<string, unknown>;
isMissingParams: boolean;
};
/**
* Interpolate params and wildcards into a route path template.
*
* - Encodes params safely (configurable allowed characters)
* - Supports `{-$optional}` segments, `{prefix{$id}suffix}` and `{$}` wildcards
*/
export declare function interpolatePath({ path, params, decoder, ...rest }: InterpolatePathOptions): InterPolatePathResult;
export {};