@types/original-url
TypeScript icon, indicating that this package has built-in type declarations

1.2.3 • Public • Published

Installation

npm install --save @types/original-url

Summary

This package contains type definitions for original-url (https://github.com/watson/original-url#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/original-url.

index.d.ts

/// <reference types="node" />

import { IncomingMessage } from "http";

export = originalUrl;

/**
 * Reconstruct the original URL used in an HTTP request based on the HTTP
 * request headers.
 *
 * The module takes into account potential URL rewrites made by proxies,
 * load balancers, etc along the way (as long as these append special HTTP
 * headers to the request).
 *
 * Supported HTTP headers:
 *
 * - `Host`
 * - `Forwarded`
 * - `X-Forwarded-Proto`
 * - `X-Forwarded-Protocol`
 * - `X-Url-Scheme`
 * - `Front-End-Https`
 * - `X-Forwarded-Ssl`
 * - `X-Forwarded-Host`
 * - `X-Forwarded-Port`
 *
 * If the protocol (http vs https) cannot be determined based on the above
 * headers, the `encrypted` flag on the TLS connection is used.
 *
 * @example
 * import * as http from 'http'
 * import originalUrl = require('original-url')
 *
 * const server = http.createServer((req, res) => {
 *   const url = originalUrl(req)
 *   if (url.full) {
 *     res.end(`Original URL: ${url.full}\n`)
 *   } else {
 *     res.end('Original URL could not be determined\n')
 *   }
 * })
 *
 * server.listen(1337)
 */
declare function originalUrl(req: IncomingMessage): originalUrl.OriginalUrl;

declare namespace originalUrl {
    interface OriginalUrl {
        raw: string | undefined;
        protocol: string;
        hostname: string | undefined;
        port?: number | undefined;
        pathname?: string | undefined;
        search?: string | undefined;
        hash?: string | undefined;
        /** The fully resolved URL. */
        full?: string | undefined;
    }
}

Additional Details

  • Last updated: Tue, 07 Nov 2023 09:09:39 GMT
  • Dependencies: @types/node

Credits

These definitions were written by BendingBender.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/original-url

Weekly Downloads

172

Version

1.2.3

License

MIT

Unpacked Size

5.81 kB

Total Files

5

Last publish

Collaborators

  • types