aimpress-chatbot/node_modules/prepend-http/index.js
“SamoilenkoVadym” 205d62e282 Your commit message
2025-04-27 19:29:04 +01:00

14 lines
288 B
JavaScript

'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://');
};