Skip to content

Commit

Permalink
Fix: Support font assets with space in URL (#8911)
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSodaSea committed Nov 30, 2022
1 parent 14a5ce9 commit 06a9562
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/assets/src/loader/parsers/loadWebFont.ts
Expand Up @@ -84,7 +84,7 @@ export const loadWebFont = {
{
const weight = weights[i];

const font = new FontFace(name, `url(${url})`, {
const font = new FontFace(name, `url(${encodeURI(url)})`, {
...data,
weight,
});
Expand Down
11 changes: 11 additions & 0 deletions packages/assets/test/assets.tests.ts
Expand Up @@ -391,4 +391,15 @@ describe('Assets', () =>

expect(font).toBeInstanceOf(FontFace);
});

it('should load font assets with space in URL', async () =>
{
await Assets.init({
basePath,
});

const font = await Assets.load('fonts/url with space.ttf');

expect(font).toBeInstanceOf(FontFace);
});
});
Binary file not shown.

0 comments on commit 06a9562

Please sign in to comment.