UNPKG

@lokalise/api-contracts

Version:

Key idea behind API contracts: backend owns entire definition for the route, including its path, HTTP method used and response structure expectations, and exposes it as a part of its API schemas. Then frontend consumes that definition instead of forming f

19 lines (18 loc) 737 B
/** * Builds a request path by combining a base path with an optional path prefix. * Ensures proper slash handling to avoid double slashes or missing slashes. * * @param path - The base path for the request * @param pathPrefix - Optional prefix to prepend to the path * @returns The combined path with proper slash formatting * * @example * ```typescript * buildRequestPath('/api/users') // '/api/users' * buildRequestPath('api/users') // '/api/users' * buildRequestPath('/api/users', 'v1') // '/v1/api/users' * buildRequestPath('/api/users', '/v1/') // '/v1/api/users' * buildRequestPath('api/users', 'v1') // '/v1/api/users' * ``` */ export declare function buildRequestPath(path: string, pathPrefix?: string): string;