Skip to content

Commit 1e5b72c

Browse files
fix(astro): invalid font url (#14487)
1 parent ae034ae commit 1e5b72c

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

.changeset/shiny-suns-sip.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Fixes a case where the URLs generated by the experimental Fonts API would be incorrect in dev

packages/astro/src/assets/fonts/implementations/url-proxy-hash-resolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ function formatWeight(
4444
if (typeof weight === 'number') {
4545
return weight.toString();
4646
}
47-
return weight;
47+
return weight?.replace(/\s+/g, '-');
4848
}

packages/astro/test/units/assets/fonts/implementations.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,5 +522,14 @@ describe('fonts implementations', () => {
522522
}),
523523
'foo-100-900-italic-cyrillic-whatever.woff2',
524524
);
525+
assert.equal(
526+
resolver.resolve({
527+
cssVariable: '--foo',
528+
data: { weight: '200 700', style: 'italic', subset: 'cyrillic' },
529+
originalUrl: 'whatever',
530+
type: 'woff2',
531+
}),
532+
'foo-200-700-italic-cyrillic-whatever.woff2',
533+
);
525534
});
526535
});

0 commit comments

Comments
 (0)