aboutsummaryrefslogtreecommitdiff
path: root/node_modules/prepend-http/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/prepend-http/index.js')
-rw-r--r--node_modules/prepend-http/index.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/node_modules/prepend-http/index.js b/node_modules/prepend-http/index.js
new file mode 100644
index 000000000..60f532ac5
--- /dev/null
+++ b/node_modules/prepend-http/index.js
@@ -0,0 +1,14 @@
+'use strict';
+module.exports = function (url) {
+ if (typeof url !== 'string') {
+ throw new TypeError('Expected a string, got ' + typeof url);
+ }
+
+ url = url.trim();
+
+ if (/^\.*\/|^(?!localhost)\w+:/.test(url)) {
+ return url;
+ }
+
+ return url.replace(/^(?!(?:\w+:)?\/\/)/, 'http://');
+};