Skip to content

Commit

Permalink
fix css rewriting (titaniumnetwork-dev#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
Avad3 authored Jul 12, 2024
1 parent d5b332d commit 51b71aa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/rewrite/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ class CSS extends EventEmitter {
recast(str, options, type) {
if (!str) return str;
str = new String(str).toString();
// no rewriting rn cry ab it
str = str.replace(/(?<=url\("?'?)[^"'][\S]*[^"'](?="?'?\);?)/gm, (match) => {
return type === "rewrite" ? this.ctx.rewriteUrl(match) : this.ctx.sourceUrl(match);
});
str = str.replace(/@import\s+(['"])?([^'"\);]+)\1?\s*(?:;|$)/gm, (match, quote, url) => {
return `@import ${quote || ""}${type === "rewrite" ? this.ctx.rewriteUrl(url) : this.ctx.sourceUrl(url)}${quote || ""};`;
});
return str;
}
}
Expand Down

0 comments on commit 51b71aa

Please sign in to comment.