From 04ddf4ba312a0ab01f054910d26a9d0d70a4bbc1 Mon Sep 17 00:00:00 2001 From: Nick Howes Date: Tue, 3 Dec 2013 13:20:56 +0000 Subject: [PATCH] Fix url.format() param type. --- node/node-tests.ts | 13 +++++++++++++ node/node.d.ts | 13 ++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/node/node-tests.ts b/node/node-tests.ts index cf73c11bc1..02566602d1 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -4,6 +4,7 @@ import assert = require("assert"); import fs = require("fs"); import events = require("events"); import zlib = require("zlib"); +import url = require('url'); assert(1 + 1 - 2 === 0, "The universe isn't how it should."); @@ -39,6 +40,18 @@ class Networker extends events.EventEmitter { } } +url.format(url.parse('http://www.example.com/xyz')); + +// https://google.com/search?q=you're%20a%20lizard%2C%20gary +url.format({ + protocol: 'https', + host: "google.com", + pathname: 'search', + query: { q: "you're a lizard, gary" } +}); + + + //////////////////////////////////////////////////// /// Stream tests : http://nodejs.org/api/stream.html //////////////////////////////////////////////////// diff --git a/node/node.d.ts b/node/node.d.ts index 5bdda94eef..bd68cc0076 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -599,8 +599,19 @@ declare module "url" { slashes: boolean; } + export interface UrlOptions { + protocol?: string; + auth?: string; + hostname?: string; + port?: string; + host?: string; + pathname?: string; + search?: string; + query?: any; + } + export function parse(urlStr: string, parseQueryString?: boolean , slashesDenoteHost?: boolean ): Url; - export function format(url: Url): string; + export function format(url: UrlOptions): string; export function resolve(from: string, to: string): string; }