UNPKG

@plurid/plurid-engine

Version:
69 lines (68 loc) 2.02 kB
import { Indexed, PluridRouteFragments, PluridRouteFragmentElement, PluridRouteFragmentText } from '@plurid/plurid-data'; import { ParserParametersAndMatch } from './interfaces'; export declare const extractPathname: (location: string) => string; /** * Extracts the parameters names from a `route`. * * e.g. * * `'/:foo/:boo'` -> `[':foo', 'boo']` * * `'/foo/:boo'` -> `['', 'boo']` * * `'/foo/boo'` -> `[]` * * If there are no parameters returns an empty array. * Non-parametric route elements have an empty string as placeholder. * * @param route */ export declare const extractParametersAndMatch: (location: string, route: string) => ParserParametersAndMatch; /** * Extract the parameters values. * * e.g. * * `parameters = ['', ':list']` * * `pathElements = ['list', 'foo']` * * `parametersValues = { list: 'foo' }` * * @param parameters * @param pathElements */ export declare const extractParametersValues: (parameters: string[], pathElements: string[]) => Record<string, string>; /** * Based on the `path` and the `parameters` computes a match for comparison. * * @param path * @param parameters */ export declare const computeComparingPath: (path: string, parameters: string[]) => { locationElements: string[]; comparingPath: string; }; /** * Splits `path` into elements. * * e.g. `'/foo/boo'` -> `['foo', 'boo']` * * @param path */ export declare const splitPath: (path: string) => string[]; /** * Extract the query values. * * e.g. * * `path = '/foo?id=1&asd=asd'` * * `query = { id: 1, asd: 'asd' }` * * @param path */ export declare const extractQuery: (path: string) => Indexed<string>; export declare const extractFragments: (location?: string) => PluridRouteFragments; export declare const parseFragment: (fragment: string) => PluridRouteFragmentText | PluridRouteFragmentElement | undefined; export declare const extractOccurence: (occurence: string | undefined) => number;