fb393e3dd5a07792e2c7a1d08a211eacf7ed2894afce9880cb4fb5a9d64ae37579a04b5d5a1c4b52174f9e22979d0e35461d15d5cbe8af3ee7e0519eef6e02 288 B

1234567891011121314
  1. 'use strict';
  2. module.exports = function (url) {
  3. if (typeof url !== 'string') {
  4. throw new TypeError('Expected a string, got ' + typeof url);
  5. }
  6. url = url.trim();
  7. if (/^\.*\/|^(?!localhost)\w+:/.test(url)) {
  8. return url;
  9. }
  10. return url.replace(/^(?!(?:\w+:)?\/\/)/, 'http://');
  11. };