blob: 25ef0bdc5c29832360cd759656f74d823d7f4ce2 [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001'use strict';
2
3
4
5// Copied from https://github.com/nodejs/node/blob/master/lib/internal/url.js
6
7function urlToOptions(url) {
8 var options = {
9 protocol: url.protocol,
10 hostname: url.hostname,
11 hash: url.hash,
12 search: url.search,
13 pathname: url.pathname,
14 path: `${url.pathname}${url.search}`,
15 href: url.href
16 };
17 if (url.port !== '') {
18 options.port = Number(url.port);
19 }
20 if (url.username || url.password) {
21 options.auth = `${url.username}:${url.password}`;
22 }
23 return options;
24}
25
26
27
28module.exports = urlToOptions;