Skip to content

Commit

Permalink
⚡ Ignore modulepreload in link tags
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickadam committed Jan 5, 2023
1 parent ac26b8d commit a3774ef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions packages/rum/src/domain/record/privacy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,16 @@ describe('getNodeSelfPrivacyLevel', () => {
html: '<script class="dd-privacy-allow">',
expected: NodePrivacyLevel.ALLOW,
},
{
msg: 'is a link with rel=preload and as=script',
html: '<link rel="preload" crossorigins as="script">',
expected: NodePrivacyLevel.IGNORE,
},
{
msg: 'is a link with rel=modulepreload and as=script',
html: '<link rel="modulepreload" as="script">',
expected: NodePrivacyLevel.IGNORE,
},

// Precedence
{
Expand Down
4 changes: 2 additions & 2 deletions packages/rum/src/domain/record/privacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ export function shouldIgnoreElement(element: Element): boolean {
if (element.nodeName === 'LINK') {
const relAttribute = getLowerCaseAttribute('rel')
return (
// Scripts
(relAttribute === 'preload' && getLowerCaseAttribute('as') === 'script') ||
// Link as script - Ignore only when rel=preload or modulepreload
(/preload/i.test(relAttribute) && getLowerCaseAttribute('as') === 'script') ||
// Favicons
relAttribute === 'shortcut icon' ||
relAttribute === 'icon'
Expand Down

0 comments on commit a3774ef

Please sign in to comment.