var get = function(url) { if(location.protocol === "http") { return url; } var reg = /^(http[s]?://)?([^/]+)(.*)/, matches = url.match(reg); url = list.hasOwnProperty(matches[2])&&(list[matches[2]] + matches[3]) || url; return url; }