Skip to content

Commit

Permalink
Fix the following typing problem in the tests:
Browse files Browse the repository at this point in the history
rrweb:test:     test/utils.ts:181:43 - error TS2345: Argument of type 'elementNode & { rootId?: number | undefined; isShadowHost?: boolean | undefined; isShadow?: boolean | undefined; } & { id: number; }' is not assignable to parameter of type '{ attributes: { src?: string | undefined; }; }'.
rrweb:test:       Types of property 'attributes' are incompatible.
rrweb:test:         Type 'attributes' has no properties in common with type '{ src?: string | undefined; }'.
rrweb:test:
rrweb:test:     181               stripBlobURLsFromAttributes(add.node);
  • Loading branch information
eoghanmurray committed Jun 11, 2024
1 parent e6b5213 commit 0b9262e
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions packages/rrweb/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,18 +242,18 @@ export function stringifySnapshots(snapshots: eventWithTime[]): string {

function stripBlobURLsFromAttributes(node: {
attributes: {
src?: string;
[key: string]: any;
};
}) {
if (
'src' in node.attributes &&
node.attributes.src &&
typeof node.attributes.src === 'string' &&
node.attributes.src.startsWith('blob:')
) {
node.attributes.src = node.attributes.src
.replace(/[\w-]+$/, '...')
.replace(/:[0-9]+\//, ':xxxx/');
for (const attr in node.attributes) {
if (
typeof node.attributes[attr] === 'string' &&
node.attributes[attr].startsWith('blob:')
) {
node.attributes[attr] = node.attributes[attr]
.replace(/[\w-]+$/, '...')
.replace(/:[0-9]+\//, ':xxxx/');
}
}
}

Expand Down

0 comments on commit 0b9262e

Please sign in to comment.