Skip to content

Commit

Permalink
chore(sirv): add test for filename with space (#102)
Browse files Browse the repository at this point in the history
* Add test case around handling file names with spaces

This is specifically for sveltejs/kit#740 to assert that sirv is working as expected.

* Apply suggestions from code review

Co-authored-by: Luke Edwards <luke.edwards05@gmail.com>
  • Loading branch information
samccone and lukeed authored Mar 29, 2021
1 parent da98454 commit ede9189
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/public/with space.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
with space.txt
26 changes: 26 additions & 0 deletions tests/sirv.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,32 @@ encode('should work when the request path contains encoded characters :: prod',
}
});

encode(`should work when the request path contains space encoded :: dev`, async () => {
let server = utils.http({ dev: true });

try {
let res = await server.send('GET', '/with%20space.txt');
assert.is(res.headers['content-type'], 'text/plain');
assert.is(res.data, 'with space.txt\n');
assert.is(res.statusCode, 200);
} finally {
server.close();
}
});

encode(`should work when the request path contains space encoded :: prod`, async () => {
let server = utils.http({ dev: false });

try {
let res = await server.send('GET', '/with%20space.txt');
assert.is(res.headers['content-type'], 'text/plain');
assert.is(res.data, 'with space.txt\n');
assert.is(res.statusCode, 200);
} finally {
server.close();
}
});

encode.run();

// ---
Expand Down

0 comments on commit ede9189

Please sign in to comment.