js 判断传入参数是域名还是地址

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;
	}
posted @ 2017-11-21 11:55  smallf  阅读(1486)  评论(0编辑  收藏  举报