Skip to content

Commit

Permalink
fix: use includes over contains (#1275)
Browse files Browse the repository at this point in the history
  • Loading branch information
daibhin authored Jun 26, 2024
1 parent f171c19 commit dd90192
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 7 additions & 5 deletions patches/rrweb@2.0.0-alpha.13.patch
Original file line number Diff line number Diff line change
Expand Up @@ -224,20 +224,22 @@ index da2c103fe6b1408a5996f0eb3bf047571e434cc2..f5b060c7e0728a3e2c6cf62b01d97282
}, [bitmap]);
}));
diff --git a/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js b/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js
index 0fc7d4bcafc9be822347f9437658478fd77d9972..a2400dbd745664cc94335f9a0d04bb52af91ee13 100644
index 0fc7d4bcafc9be822347f9437658478fd77d9972..5dcd1dcbd5380567110378269f3bc8d7b7ca6440 100644
--- a/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js
+++ b/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js
@@ -641,9 +641,17 @@ function serializeElementNode(n, options) {
@@ -641,9 +641,18 @@ function serializeElementNode(n, options) {
}
}
if (tagName === 'link' && inlineStylesheet) {
- const stylesheet = Array.from(doc.styleSheets).find((s) => {
- return s.href === n.href;
+ const href = n.href
+ let stylesheet = Array.from(doc.styleSheets).find((s) => {
return s.href === n.href;
+ return s.href === href;
});
+ if (!stylesheet && n.href.contains('.css')) {
+ if (!stylesheet && href.includes('.css')) {
+ const rootDomain = window.location.origin
+ const stylesheetPath = n.href.replace(window.location.href, '')
+ const stylesheetPath = href.replace(window.location.href, '')
+ const potentialStylesheetHref = rootDomain + '/' + stylesheetPath
+ stylesheet = Array.from(doc.styleSheets).find((s) => {
+ return s.href === potentialStylesheetHref;
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dd90192

Please sign in to comment.