-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(web): correctly resolve assets in new URL (#3950)
- Loading branch information
1 parent
867dbf6
commit a428f8d
Showing
7 changed files
with
49 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// @vitest-environment node | ||
|
||
import { fileURLToPath, pathToFileURL } from 'node:url' | ||
import { dirname, resolve } from 'pathe' | ||
import { expect, it } from 'vitest' | ||
|
||
it('correctly resolves new assets URL paths', () => { | ||
const urlCss = new URL('../src/file-css.css', import.meta.url) | ||
expect(urlCss.toString()).toBe( | ||
pathToFileURL(resolve(dirname(fileURLToPath(import.meta.url)), '../src/file-css.css')).toString(), | ||
) | ||
}) | ||
|
||
it('doesn\'t resolve aliases for new URL in SSR', () => { | ||
const urlAlias = new URL('#/file-css.css', import.meta.url) | ||
expect(urlAlias.toString()).toBe( | ||
pathToFileURL(`${fileURLToPath(import.meta.url)}#/file-css.css`).toString().replace('%23', '#'), | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// @vitest-environment jsdom | ||
|
||
import { expect, it } from 'vitest' | ||
|
||
it('correctly resolves new assets URL paths', () => { | ||
const urlCss = new URL('../src/file-css.css', import.meta.url) | ||
expect(urlCss.toString()).toBe('http://localhost:3000/src/file-css.css') | ||
}) | ||
|
||
it('correctly resolves aliased URL paths', () => { | ||
const urlAlias = new URL('#/file-css.css', import.meta.url) | ||
expect(urlAlias.toString()).toBe('http://localhost:3000/src/file-css.css') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters