import type { IncomingMessage } from 'node:http'; import type { Qs } from './qs.js'; import type { Response } from './response.js'; import type { Router } from './router/main.js'; import type { MakeUrlOptions } from './types/route.js'; import type { ResponseConfig } from './types/response.js'; /** * Exposes the API to construct redirect routes */ export declare class Redirect { #private; /** * Array of allowed hosts for referrer-based redirects. * When empty, only the request's own host is allowed. */ allowedHosts: string[]; constructor(request: IncomingMessage, response: Response, router: Router, qs: Qs, config: ResponseConfig['redirect']); /** * Returns the previous URL for redirect back. By default reads * the `Referer` header and validates the host. * * @param fallback - URL to return when no valid previous URL is found */ getPreviousUrl(fallback: string): string; /** * Set a custom status code. */ status(statusCode: number): this; /** * Clearing query string values added using the * "withQs" method */ clearQs(): this; /** * Define query string for the redirect. Not passing * any value will forward the current request query * string. */ withQs(): this; withQs(forward: boolean): this; withQs(values: Record): this; withQs(name: string, value: any): this; /** * Redirects to the previous URL resolved via `getPreviousUrl`. * * @param fallback - URL to redirect to when no valid previous URL is found */ back(fallback?: string): void; /** * Redirect the request using a route identifier. */ toRoute(routeIdentifier: string, params?: any[] | Record, options?: MakeUrlOptions): void; /** * Redirect the request using a path. */ toPath(url: string): void; }