fix fbclid url sanitizer
This commit is contained in:
parent
ce82e8477c
commit
fa91646a6a
1 changed files with 2 additions and 2 deletions
|
@ -19,7 +19,7 @@ const DOMPurify = require('dompurify')
|
|||
const { JSDOM } = require('jsdom')
|
||||
const { window } = new JSDOM('<!DOCTYPE html>')
|
||||
const domPurify = DOMPurify(window)
|
||||
const url = require('url')
|
||||
const URL = require('url')
|
||||
|
||||
domPurify.addHook('beforeSanitizeElements', node => {
|
||||
if (node.hasAttribute && node.hasAttribute('href')) {
|
||||
|
@ -29,7 +29,7 @@ domPurify.addHook('beforeSanitizeElements', node => {
|
|||
// remove FB tracking param
|
||||
if (href.includes('fbclid=')) {
|
||||
try {
|
||||
const url = new url.URL(href)
|
||||
const url = new URL.URL(href)
|
||||
url.searchParams.delete('fbclid')
|
||||
node.setAttribute('href', url.href)
|
||||
if (text.includes('fbclid=')) {
|
||||
|
|
Loading…
Reference in a new issue