Skip to content

Commit dbe52a1

Browse files
committed
fix: improve CSS src property parsing in font faces
- Fix regex pattern to handle src properties ending with } instead of ; - Update both dedupeFontFaces and embedCustomFonts functions
1 parent 695e28f commit dbe52a1

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/modules/fonts.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ function dedupeFontFaces(cssText) {
432432
const styleSpec = (block.match(/font-style:\s*([^;]+);/i)?.[1] || 'normal').trim()
433433
const stretchSpec = (block.match(/font-stretch:\s*([^;]+);/i)?.[1] || '100%').trim()
434434
const urange = (block.match(/unicode-range:\s*([^;]+);/i)?.[1] || '').trim()
435-
const srcRaw = (block.match(/src\s*:\s*([^;]+);/i)?.[1] || '').trim()
435+
const srcRaw = (block.match(/src\s*:\s*([^;}]+)[;}]/i)?.[1] || '').trim()
436436

437437
const urls = extractSrcUrls(srcRaw, location.href)
438438
const srcPart = urls.length
@@ -720,7 +720,7 @@ export async function embedCustomFonts({
720720
const styleSpec = (face.match(/font-style:\s*([^;]+);/i)?.[1] || 'normal').trim()
721721
const stretchSpec = (face.match(/font-stretch:\s*([^;]+);/i)?.[1] || '100%').trim()
722722
const urange = (face.match(/unicode-range:\s*([^;]+);/i)?.[1] || '').trim()
723-
const srcRaw = (face.match(/src\s*:\s*([^;]+);/i)?.[1] || '').trim()
723+
const srcRaw = (face.match(/src\s*:\s*([^;}]+)[;}]/i)?.[1] || '').trim()
724724
const srcUrls = extractSrcUrls(srcRaw, link.href)
725725

726726
if (!faceMatchesRequired(family, styleSpec, weightSpec, stretchSpec)) continue

0 commit comments

Comments
 (0)