📜  从字符串中删除参数 - 无论代码示例

📅  最后修改于: 2022-03-11 14:58:07.182000             🧑  作者: Mango

代码示例1
function removeParameterFromUrl(url, parameter) {
  const replacer = (m, p1, p2) => (p1 === '?' && p2 === '&' ? '?' : p2 || '')
  return url.replace(new RegExp(`([?&])${parameter}=[^&#]+([&#])?`), replacer)
}