import { ParsedUrl } from '@autogram/url-tools'; export interface NormalizerOptions { /** * Coerce the URL's protocol; primarily useful for changing http: to https: */ forceProtocol?: 'https:' | 'http:' | false; /** * Run a portion of the domain through strToLower(). */ forceLowercase?: string | string[] | boolean; /** * Discard the entire subdomain if it matches a glob pattern. */ discardSubdomain?: string | false; /** * Discard the first segment of the hostname if it matches a glob pattern. */ discardFirstSegment?: string | false; /** * If the url's subdomain is empty, use the one specified. */ supplySubdomain?: string | false; /** * Remove the URL anchor/hashtag if it exists. */ discardAnchor?: boolean; /** * Remove the URL authentication fields (username and password) if they exist. */ discardAuth?: boolean; /** * Remove the port number if it matches a glob pattern. */ discardPort?: string | boolean; /** * If the pathname matches the supplied pattern, remove its final segment. * * Useful for stripping `/index.html` and `/Default.aspx` style filenames that * fall back to `/` on well-configured servers. */ discardIndex?: string | false; /** * Discard any search/querystring parameters whose names match the supplied pattern. */ discardSearch?: string; /** * Remove the trailing slash from the URL path if it exists. This is risky depending on * the server configuration. */ discardTrailingSlash?: boolean; /** * For any search/querystring parameters whose names match the supplied pattern, collapse * multiple values and use only the last one. Setting the property to `true` collapses * all search parameters regardless of name. * * @example * ``` * const url = new ParsedUrl('https://example.com/search.html?page=1&page=2&page=3'); * const newUrl = globalNormalizer(url, { collapseSearchParams: 'page' }); * console.log(newUrl.href); * // https://example.com/search.html?page=3 * ``` */ collapseSearchParams?: true | string; /** * Alphabetize any search/querystring parameters, so links that supply params in different * orders are not incorrectly flagged as different URLs. */ sortSearchParams?: boolean; /** * An optional list of strings to find and replace in the URL. The `match` property, if * it starts and ends with the `/` character, can be a regular expression. */ replace?: UrlReplacement | UrlReplacement[]; } interface UrlReplacement { match: string | RegExp; value: string; all?: boolean; } export declare function globalNormalizer(url: ParsedUrl, opts?: NormalizerOptions): ParsedUrl; export {}; //# sourceMappingURL=global-normalizer.d.ts.map