目标:获取到当前域名,并附加到 /ws/wstest.json
接口前。
var reg = /^http(s?:\/\/(.*))\/.*$/
var wsUrl = window.location.href.replace(reg, 'ws$1/ws/wstest.json')
上面的reg可匹配
http(s)://xxx.xxx.xx/
http(s)://xxx.xxx.xx/xx/xx.xx
将被替换为
ws(s)://xxx.xxx.xx/ws/wstest.json
网友评论