mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 06:50:01 -04:00
Update css.ts
This commit is contained in:
parent
fb18c8af9f
commit
2f4c0b4d43
1 changed files with 2 additions and 2 deletions
|
@ -1,9 +1,9 @@
|
||||||
import { encodeUrl } from "./url";
|
import { encodeUrl } from "./url";
|
||||||
|
|
||||||
export function rewriteCss(css: string, origin?: URL) {
|
export function rewriteCss(css: string, origin?: URL) {
|
||||||
css = css.replace(/(?<=url\("?'?)[^"'][\S]*[^"'](?="?'?\);?)/g, (match) => encodeUrl(match, origin));
|
css = css.replace(/(?<=url\("?'?)[^"'][\S]*[^"'](?="?'?\);?)/gm, (match) => encodeUrl(match, origin));
|
||||||
//painful regex simulator
|
//painful regex simulator
|
||||||
css = css.replace(/@import\s+(['"])?([^'"\);]+)\1?\s*(?:;|$)/g, (match, quote, url) => {
|
css = css.replace(/@import\s+(['"])?([^'"\);]+)\1?\s*(?:;|$)/gm, (match, quote, url) => {
|
||||||
return `@import ${quote || ""}${encodeUrl(url.trim(), origin)}${quote || ""};`;
|
return `@import ${quote || ""}${encodeUrl(url.trim(), origin)}${quote || ""};`;
|
||||||
});
|
});
|
||||||
return css;
|
return css;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue