Skip to content

Instantly share code, notes, and snippets.

@Jason-Rev
Created June 6, 2016 15:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Jason-Rev/db690a4a511d571203f02517ec1f7480 to your computer and use it in GitHub Desktop.
Save Jason-Rev/db690a4a511d571203f02517ec1f7480 to your computer and use it in GitHub Desktop.
Typings for npm url-parse
declare module 'url-parse' {
interface Query {
[index: string]: string;
}
interface QueryParser {
(query: string): any;
}
interface ParsedUrl {
(url: string, baseURL?: string, parseQuery?: boolean|QueryParser): ParsedUrl;
new (url: string, baseURL?: string, parseQuery?: boolean|QueryParser): ParsedUrl;
protocol: string; // protocol: Requested protocol without slashes (e.g. http:).
username: string; // username: Username of basic authentication.
password: string; // password: Password of basic authentication.
auth: string; // auth: Authentication information portion (e.g. username:password).
host: string; // host: Host name with port number.
hostname: string; // hostname: Host name without port number.
port: number; // port: Optional port number.
pathname: string; // pathname: URL path.
query: Query; // query: Parsed object containing query string, unless parsing is set to false.
hash: string; // hash: The "fragment" portion of the URL including the pound-sign (#).
href: string; // href: The full URL.
toString(): string;
set(key: string, value: string|Object|number);
}
const URL: ParsedUrl;
export = URL;
}
@nertzy
Copy link

nertzy commented Aug 15, 2016

@Jason-Rev would you be willing to submit this to https://github.com/DefinitelyTyped/DefinitelyTyped ?

@nertzy
Copy link

nertzy commented Aug 15, 2016

Also line 20 (port) should be a string, not a number, based on what the library actually returns.

I've updated it in my fork.

@nertzy
Copy link

nertzy commented Sep 26, 2016

Also, on line 27, set() returns ParsedUrl. Also updated in my fork.

@nertzy
Copy link

nertzy commented Dec 6, 2016

@Jason-Rev would you be willing to release this under the MIT license? If so, I can pull it into https://github.com/DefinitelyTyped/DefinitelyTyped and get it up on NPM for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment