From 40a5974a0ebebe1553b363a65aa629bec2431340 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 8 Jun 2016 15:27:57 -0700 Subject: [PATCH] doc: `url.format()` parameter may be a string PR-URL: https://github.com/nodejs/node/pull/7235 Reviewed-By: James M Snell Reviewed-By: cjihrig - Colin Ihrig --- doc/api/url.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/api/url.md b/doc/api/url.md index c041f9bd8f..ea3075accd 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -135,13 +135,17 @@ For example: `'#hash'` added: v0.1.25 --> -* `urlObject` {Object} A URL object (either as returned by `url.parse()` or - constructed otherwise). +* `urlObject` {Object | String} A URL object (as returned by `url.parse()` or + constructed otherwise). If a string, it is converted to an object by passing + it to `url.parse()`. -The `url.format()` method processes the given URL object and returns a formatted -URL string. +The `url.format()` method returns a formatted URL string derived from +`urlObject`. -The formatting process essentially operates as follows: +If `urlObject` is not an object or a string, `url.parse()` will throw a +[`TypeError`][]. + +The formatting process operates as follows: * A new empty string `result` is created. * If `urlObject.protocol` is a string, it is appended as-is to `result`. @@ -247,3 +251,4 @@ forward slash (`/`) character is encoded as `%3C`. [`Error`]: errors.html#errors_class_error [`querystring`]: querystring.html +[`TypeError`]: errors.html#errors_class_typeerror