Skip to content

Commit

Permalink
allow symlinked assets
Browse files Browse the repository at this point in the history
prettier

skip test on windows

Revert "skip test on windows"

This reverts commit f8e55e6.

skip test completely
  • Loading branch information
gaarf committed May 27, 2022
1 parent 2f5ec06 commit 14e0101
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/violet-walls-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

allow symlinked static assets in dev
2 changes: 1 addition & 1 deletion packages/kit/src/core/dev/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export async function create_plugin(config) {
const file = config.kit.files.assets + pathname;

if (fs.existsSync(file) && !fs.statSync(file).isDirectory()) {
const has_correct_case = fs.realpathSync.native(file) === path.resolve(file);
const has_correct_case = fs.realpathSync.native(file).endsWith(pathname);

if (has_correct_case) {
req.url = encodeURI(pathname); // don't need query/hash
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<svelte:head>
<link rel="stylesheet" href="/symlinked/asset.css" />
</svelte:head>

<h1>are symlinked assets served?</h1>
<p id="symlinktest">blue = ok</p>

7 changes: 7 additions & 0 deletions packages/kit/test/apps/basics/src/symlinked/asset.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#symlinktest {
font-size: x-large;
color: blue;
}
#symlinktest::before {
content: 'YES! ';
}
1 change: 1 addition & 0 deletions packages/kit/test/apps/basics/static/symlinked
6 changes: 6 additions & 0 deletions packages/kit/test/apps/basics/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2583,6 +2583,12 @@ test.describe.parallel('Static files', () => {
const response = await request.get('/static.JSON');
expect(response.status()).toBe(404);
});

// FIXME: disable on windows only
test.skip('Serves symlinked asset', async ({ request }) => {
const response = await request.get('/symlinked/asset.css');
expect(response.status()).toBe(200);
});
});

test.describe.parallel('Matchers', () => {
Expand Down

0 comments on commit 14e0101

Please sign in to comment.