Skip to content

Instantly share code, notes, and snippets.

@weikx
Created June 25, 2021 10:21
Show Gist options
  • Save weikx/fc48fa05bf662d43c484e8e60c7a5aea to your computer and use it in GitHub Desktop.
Save weikx/fc48fa05bf662d43c484e8e60c7a5aea to your computer and use it in GitHub Desktop.
// 特殊情况用的特殊处理代码
const url = 'http://m.xianmaiyangsheng.com/invitation?otherId=761173&time&otherCode'
String.prototype.replaceAll = function(s1, s2) {
return this.replace(new RegExp(s1, 'gm'), s2)
}
function getUrlPatam(url, name) {
// 获取地址栏参数
url = decodeURIComponent(url).split('?')[1].replaceAll('&', '_and_').split('_and_').map(item => item.split('='))
url = url.filter(item => item[0] === name).flat()
return url[1]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment