Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix relative path detection in stylesheet URLs
  • Loading branch information
Equlnox authored Feb 14, 2023
commit 84368dc9dc6a8bde00040a8ff6eee92799b7c00a
4 changes: 2 additions & 2 deletions packages/rrweb-snapshot/src/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ let canvasService: HTMLCanvasElement | null;
let canvasCtx: CanvasRenderingContext2D | null;

const URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
const RELATIVE_PATH = /^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/;
const ABSOLUTE_PATH = /^(?:[a-z+]+:)?\/\//i;
const DATA_URI = /^(data:)([^,]*),(.*)/i;
export function absoluteToStylesheet(
cssText: string | null,
Expand All @@ -92,7 +92,7 @@ export function absoluteToStylesheet(
if (!filePath) {
return origin;
}
if (!RELATIVE_PATH.test(filePath)) {
if (ABSOLUTE_PATH.test(filePath)) {
return `url(${maybeQuote}${filePath}${maybeQuote})`;
}
if (DATA_URI.test(filePath)) {
Expand Down