projects
/
dotfiles
/
.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
60f532ac59c4144ad1d8225a1bfcdb48a32793d3
[dotfiles/.git]
/
index.js
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
7
url = url.trim();
8
9
if (/^\.*\/|^(?!localhost)\w+:/.test(url)) {
10
return url;
11
}
12
13
return url.replace(/^(?!(?:\w+:)?\/\/)/, 'http://');
14
};