summaryrefslogtreecommitdiff
path: root/doc/api/url.md
diff options
context:
space:
mode:
authorVse Mozhet Byt <vsemozhetbyt@gmail.com>2017-05-30 00:25:41 +0300
committerVse Mozhet Byt <vsemozhetbyt@gmail.com>2017-06-01 02:23:11 +0300
commitf1b2e68d651e4fb68ad3b27e1138542673d3b502 (patch)
tree70449632bafd5a57f05ca32a2d0dafcb3320e8bf /doc/api/url.md
parentae6c7044c8d48cc8e7c267efca7429d5aa4df993 (diff)
downloadandroid-node-v8-f1b2e68d651e4fb68ad3b27e1138542673d3b502.tar.gz
android-node-v8-f1b2e68d651e4fb68ad3b27e1138542673d3b502.tar.bz2
android-node-v8-f1b2e68d651e4fb68ad3b27e1138542673d3b502.zip
doc: fix code examples in url.md
* Update outputs. * Refine spaces. * Restore missing part. PR-URL: https://github.com/nodejs/node/pull/13288 Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'doc/api/url.md')
-rw-r--r--doc/api/url.md16
1 files changed, 9 insertions, 7 deletions
diff --git a/doc/api/url.md b/doc/api/url.md
index 06a5618949..a74ca26e08 100644
--- a/doc/api/url.md
+++ b/doc/api/url.md
@@ -101,7 +101,7 @@ that an effort will be made to coerce the given values into strings. For
instance:
```js
-const myURL = new URL({toString: () => 'https://example.org/'});
+const myURL = new URL({ toString: () => 'https://example.org/' });
// https://example.org/
```
@@ -186,6 +186,7 @@ console.log(myURL.href);
// Prints https://example.org/foo
myURL.href = 'https://example.com/bar';
+console.log(myURL.href);
// Prints https://example.com/bar
```
@@ -332,7 +333,7 @@ console.log(myURL.protocol);
myURL.protocol = 'ftp';
console.log(myURL.href);
- // Prints ftp://example.org
+ // Prints ftp://example.org/
```
Invalid URL protocol values assigned to the `protocol` property are ignored.
@@ -380,7 +381,7 @@ console.log(myURL.username);
myURL.username = '123';
console.log(myURL.href);
- // Prints https://123:xyz@example.com
+ // Prints https://123:xyz@example.com/
```
Any invalid URL characters appearing in the value assigned the `username`
@@ -515,7 +516,7 @@ const params = new URLSearchParams({
query: ['first', 'second']
});
console.log(params.getAll('query'));
- // Prints ['first,second']
+ // Prints [ 'first,second' ]
console.log(params.toString());
// Prints 'user=abc&query=first%2Csecond'
```
@@ -571,7 +572,8 @@ console.log(params.toString());
new URLSearchParams([
['user', 'abc', 'error']
]);
- // Throws TypeError: Each query pair must be a name/value tuple
+ // Throws TypeError [ERR_INVALID_TUPLE]:
+ // Each query pair must be an iterable [name, value] tuple
```
#### urlSearchParams.append(name, value)
@@ -816,8 +818,8 @@ console.log(myURL.href);
console.log(myURL.toString());
// Prints https://a:b@xn--6qqa088eba/?abc#foo
-console.log(url.format(myURL, {fragment: false, unicode: true, auth: false}));
- // Prints 'https://你好你好?abc'
+console.log(url.format(myURL, { fragment: false, unicode: true, auth: false }));
+ // Prints 'https://你好你好/?abc'
```
## Legacy URL API