From 8d21ac9216f47c1a4739b5deb4df266a98fa2160 Mon Sep 17 00:00:00 2001 From: davidgoli Date: Thu, 3 Jan 2019 18:09:14 -0800 Subject: [PATCH] add extra parse signature --- types/url-parse/index.d.ts | 6 +++++- types/url-parse/url-parse-tests.ts | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/types/url-parse/index.d.ts b/types/url-parse/index.d.ts index 58a14f3f4d..4d33354e9e 100644 --- a/types/url-parse/index.d.ts +++ b/types/url-parse/index.d.ts @@ -1,6 +1,9 @@ // Type definitions for url-parse 1.4 // Project: https://github.com/unshiftio/url-parse -// Definitions by: Pavlo Chernenko , Hari Sivaramakrishnan , Dmitry Dushkin +// Definitions by: Pavlo Chernenko +// Hari Sivaramakrishnan +// Dmitry Dushkin +// David Golightly // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -43,6 +46,7 @@ interface URLParse { declare const URLParse: { new(address: string, location?: string | object, parser?: boolean | URLParse.QueryParser): URLParse; (address: string, location?: string | object, parser?: boolean | URLParse.QueryParser): URLParse; + (address: string, parser?: boolean | URLParse.QueryParser): URLParse; extractProtocol(url: string): { slashes: boolean; diff --git a/types/url-parse/url-parse-tests.ts b/types/url-parse/url-parse-tests.ts index 87904b7f13..be8b8afe8c 100644 --- a/types/url-parse/url-parse-tests.ts +++ b/types/url-parse/url-parse-tests.ts @@ -5,6 +5,10 @@ new URL('foo/bar', 'https://github.com/'); new URL('foo/bar', 'https://github.com/', (query: string) => ({ query })); parse('foo/bar', 'https://github.com/'); parse('foo/bar', 'https://github.com/', (query: string) => ({ query })); +const result = parse('foo/bar?baz=quux', true); +if (result.query.baz !== 'quux') { + throw new Error('bad query parsing'); +} const url1: URL = new URL('https://github.com/foo/bar?baz=true'); url1.hash;