DefinitelyTyped/types/url-parse/index.d.ts
wd39 5669dfcdbc Adding type definitions for url-parse npm package (#20233)
* Adding typings for url-parse

* Fixup! import URLSearchParams types

* Adding typings for parse function

* Changes to tsconfig and tslint

* Fixes to the type definitions

* Adding missing tslint file

* Fixing the typos in the header

* Exporting object in a diferent way, adding one more constructor signature and relevant tests

* Removing unnecessary lines from typedef
2017-10-04 11:14:33 -07:00

53 lines
1.6 KiB
TypeScript

// Type definitions for url-parse 1.1
// Project: https://github.com/unshiftio/url-parse
// Definitions by: Pavlo Chernenko <https://github.com/ChernenkoPaul>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import URLSearchParams = require("url-search-params");
type UrlQueryParamsParser = (url: string) => string;
declare class 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) => URL;
type ParseFunctionType = (url: string, baseURL?: object | string, parser?: boolean | UrlQueryParamsParser) => 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;