Skip to content

Commit 910491c

Browse files
authored
fix: change ignore all preload (#52)
1 parent 241302e commit 910491c

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

packages/rrweb-snapshot/src/rebuild.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ import {
88
type legacyAttributes,
99
} from '@posthog/rrweb-types';
1010
import { type tagMap, type BuildCache } from './types';
11-
import { isElement, Mirror, isNodeMetaEqual } from './utils';
11+
import {
12+
isElement,
13+
Mirror,
14+
isNodeMetaEqual,
15+
extractFileExtension,
16+
} from './utils';
1217
import postcss from 'postcss';
1318

1419
const tagMap: tagMap = {
@@ -271,16 +276,15 @@ function buildNode(
271276
continue;
272277
} else if (
273278
tagName === 'link' &&
274-
(n.attributes.rel === 'preload' ||
275-
n.attributes.rel === 'modulepreload') &&
276-
n.attributes.as === 'script'
279+
((n.attributes.rel === 'preload' && n.attributes.as === 'script') ||
280+
n.attributes.rel === 'modulepreload')
277281
) {
278282
// ignore
279283
} else if (
280284
tagName === 'link' &&
281285
n.attributes.rel === 'prefetch' &&
282286
typeof n.attributes.href === 'string' &&
283-
n.attributes.href.endsWith('.js')
287+
extractFileExtension(n.attributes.href) === 'js'
284288
) {
285289
// ignore
286290
} else if (

packages/rrweb-snapshot/src/snapshot.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -851,9 +851,8 @@ function slimDOMExcluded(
851851
(sn.tagName === 'script' ||
852852
// (module)preload link
853853
(sn.tagName === 'link' &&
854-
(sn.attributes.rel === 'preload' ||
855-
sn.attributes.rel === 'modulepreload') &&
856-
sn.attributes.as === 'script') ||
854+
((sn.attributes.rel === 'preload' && sn.attributes.as === 'script') ||
855+
sn.attributes.rel === 'modulepreload')) ||
857856
// prefetch link
858857
(sn.tagName === 'link' &&
859858
sn.attributes.rel === 'prefetch' &&

0 commit comments

Comments
 (0)