import type { IncomingHttpHeaders } from 'node:http'; import { Route } from './router/route.js'; import { BriskRoute } from './router/brisk.js'; import { RouteGroup } from './router/group.js'; import type { RouteJSON } from './types/route.js'; import { RouteResource } from './router/resource.js'; /** * Validates that a URL is safe to use as a redirect destination. * * - Relative URLs must start with `/` and not be protocol-relative (`//`) * - Absolute URLs must parse successfully and their host must match * `currentHost` or be listed in `allowedHosts` * * When `currentHost` and `allowedHosts` are omitted, absolute URLs * are accepted as long as they parse successfully. * * @param url - The URL to validate * @param currentHost - The current request's Host header value * @param allowedHosts - Array of additionally allowed hosts */ export declare function isValidRedirectUrl(url: string, currentHost?: string, allowedHosts?: string[]): boolean; /** * Returns the previous URL from the request's `Referer` header, * validated against the request's `Host` header and an optional * list of allowed hosts using `isValidRedirectUrl`. * * @param headers - The incoming request headers * @param allowedHosts - Array of allowed referrer hosts * @param fallback - URL to return when referrer is missing or invalid */ export declare function getPreviousUrl(headers: IncomingHttpHeaders, allowedHosts: string[], fallback: string): string; /** * Makes input string consistent by having only the starting * slash */ export declare function dropSlash(input: string): string; /** * Returns a flat list of routes from the route groups and resources */ export declare function toRoutesJSON(routes: (RouteGroup | Route | RouteResource | BriskRoute)[]): RouteJSON[]; /** * Helper to know if the remote address should * be trusted. */ export declare function trustProxy(remoteAddress: string, proxyFn: (addr: string, distance: number) => boolean): boolean; /** * Parses a range expression to an object filled with the range */ export declare function parseRange(range: string, value: T): Record;