aboutsummaryrefslogtreecommitdiff
path: root/node_modules/url-to-options/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/url-to-options/index.js')
-rw-r--r--node_modules/url-to-options/index.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/node_modules/url-to-options/index.js b/node_modules/url-to-options/index.js
new file mode 100644
index 0000000..25ef0bd
--- /dev/null
+++ b/node_modules/url-to-options/index.js
@@ -0,0 +1,28 @@
+'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;