Skip to content

Commit 4c58202

Browse files
committed
doc: url.resolve() method's behaviour
doc: url.resolve() method behaviour
1 parent 90cd39f commit 4c58202

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

doc/api/url.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,19 @@ url.resolve('http://example.com/', '/one') // 'http://example.com/one'
235235
url.resolve('http://example.com/one', '/two') // 'http://example.com/two'
236236
```
237237

238+
Note that `url.resolve()` method depends on the protocol given in the `from` parameter.
239+
Some protocols like `https`, `file`, `ftp`, `wss` and `gopher` have special cases.
240+
241+
For example:
242+
243+
```js
244+
url.resolve('https://foo.tld', 'bar') // 'https://foo.tld/bar'
245+
url.resolve('wss://foo.tld', 'bar') // 'wss://bar'
246+
url.resolve('ftps://foo.tld', 'bar') // 'ftps://bar'
247+
```
248+
249+
Although, the uniform behaviour of the method is achieved when the URL ends with a slash.
250+
238251
## Escaped Characters
239252

240253
URLs are only permitted to contain a certain range of characters. Spaces (`' '`)

0 commit comments

Comments
 (0)