Files
DefinitelyTyped/types/url-parse/index.d.ts
Hari Sivaramakrishnan 9b1c19d214 [url-parse] Export URL definition in url-parse (#27125)
* Export URL in url-parse

* Add to definitions by list
2018-07-13 13:02:09 -07:00

56 lines
1.8 KiB
TypeScript

// Type definitions for url-parse 1.1
// Project: https://github.com/unshiftio/url-parse
// Definitions by: Pavlo Chernenko <https://github.com/ChernenkoPaul>
// Hari Sivaramakrishnan <https://github.com/harisiva>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import URLSearchParams = require("url-search-params");
type UrlQueryParamsParser = (url: string) => string;
declare namespace parse {
interface URL {
readonly auth: string;
readonly hash: string;
readonly host: string;
readonly hostname: string;
readonly href: string;
readonly origin: string;
readonly password: string;
readonly pathname: string;
readonly port: string;
readonly protocol: string;
query: { [key: string]: string | undefined };
readonly search: string;
set(property: string, value: string | object | number | undefined): URL;
readonly slashes: boolean;
readonly username: string;
readonly searchParams: URLSearchParams;
toString(): string;
}
}
type ParseFunctionNodeType = (url: string, parseQueryString?: boolean, slashesDenoteHost?: boolean) => parse.URL;
type ParseFunctionType = (url: string, baseURL?: object | string, parser?: boolean | UrlQueryParamsParser) => parse.URL;
interface Protocol {
slashes: boolean;
protocol: string;
rest: string;
}
type ExtractProtocolFunctionType = (url: string) => Protocol;
type LocationFunctionType = (url: string) => string;
interface ExtendedParseFunctionType extends ParseFunctionNodeType, ParseFunctionType {
extractProtocol: ExtractProtocolFunctionType;
location: LocationFunctionType;
qs: any;
}
declare const parse: ExtendedParseFunctionType;
export = parse;