From 99508d0a19f874bc5ad361318ba2f401d03d83bd Mon Sep 17 00:00:00 2001 From: nobody Date: Fri, 30 Oct 2020 23:19:39 +0800 Subject: [PATCH] Fix css incorrect --- src/css.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/css.ts b/src/css.ts index 9d8ba88..ab83b55 100644 --- a/src/css.ts +++ b/src/css.ts @@ -13,17 +13,17 @@ class CSS { return data || ''; }; - style = style.replace(/\(['|"]/gm, '(').replace(/['|"]\)/gm, ')'); const regexp = /(?<=url\().*?(?=\))/gm; const matches = style.matchAll(regexp); const rules = new Map(); for (const m of matches) { if (m !== null && m.length > 0) { - const resourceURL = m[0]; + let resourceURL = m[0]; if (resourceURL.startsWith('data:')) { continue; } + resourceURL = resourceURL.replace(/['|"]/g, '').replace(/['|"]/g, ''); const data = await convert(resourceURL, baseURL); rules.set(resourceURL, Buffer.from(data).toString()); }