-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Disqus blinking Privacy Policy (#3493)
* Fix Disqus blinking Privacy Policy * Improve selector and add clean url params * Update validUntil * Lint --------- Co-authored-by: Clément Biron <[email protected]>
- Loading branch information
1 parent
d6ab5ed
commit b8b6ace
Showing
3 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export function cleanHref(document) { | ||
Array.from(document.querySelectorAll('a')).forEach(link => { | ||
link.href = cleanURLParams(link.href); | ||
}); | ||
} | ||
|
||
export function cleanSrc(document) { | ||
Array.from(document.querySelectorAll('img')).forEach(img => { | ||
img.src = cleanURLParams(img.src); | ||
}); | ||
} | ||
|
||
function cleanURLParams(url) { | ||
const searchString = 'https://downloads.intercomcdn.com'; | ||
|
||
if (url.includes(searchString)) { | ||
try { | ||
const parsedUrl = new URL(url); | ||
|
||
parsedUrl.searchParams.delete('expires'); | ||
parsedUrl.searchParams.delete('req'); | ||
parsedUrl.searchParams.delete('signature'); | ||
const cleanedUrl = parsedUrl.toString(); | ||
|
||
return cleanedUrl; | ||
} catch (error) { | ||
return url; | ||
} | ||
} | ||
|
||
return url; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters