You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
553 B
29 lines
553 B
'use strict';
|
|
|
|
|
|
|
|
// Copied from https://github.com/nodejs/node/blob/master/lib/internal/url.js
|
|
|
|
function urlToOptions(url) {
|
|
var options = {
|
|
protocol: url.protocol,
|
|
hostname: url.hostname,
|
|
hash: url.hash,
|
|
search: url.search,
|
|
pathname: url.pathname,
|
|
path: `${url.pathname}${url.search}`,
|
|
href: url.href
|
|
};
|
|
if (url.port !== '') {
|
|
options.port = Number(url.port);
|
|
}
|
|
if (url.username || url.password) {
|
|
options.auth = `${url.username}:${url.password}`;
|
|
}
|
|
return options;
|
|
}
|
|
|
|
|
|
|
|
module.exports = urlToOptions;
|