diff options
Diffstat (limited to 'deps/npm/node_modules/prepend-http/index.js')
-rw-r--r-- | deps/npm/node_modules/prepend-http/index.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/deps/npm/node_modules/prepend-http/index.js b/deps/npm/node_modules/prepend-http/index.js new file mode 100644 index 0000000000..60f532ac59 --- /dev/null +++ b/deps/npm/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://'); +}; |