Skip to content

Commit ede9189

Browse files
samcconelukeed
andauthored
chore(sirv): add test for filename with space (#102)
* 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>
1 parent da98454 commit ede9189

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

tests/public/with space.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
with space.txt

tests/sirv.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,32 @@ encode('should work when the request path contains encoded characters :: prod',
123123
}
124124
});
125125

126+
encode(`should work when the request path contains space encoded :: dev`, async () => {
127+
let server = utils.http({ dev: true });
128+
129+
try {
130+
let res = await server.send('GET', '/with%20space.txt');
131+
assert.is(res.headers['content-type'], 'text/plain');
132+
assert.is(res.data, 'with space.txt\n');
133+
assert.is(res.statusCode, 200);
134+
} finally {
135+
server.close();
136+
}
137+
});
138+
139+
encode(`should work when the request path contains space encoded :: prod`, async () => {
140+
let server = utils.http({ dev: false });
141+
142+
try {
143+
let res = await server.send('GET', '/with%20space.txt');
144+
assert.is(res.headers['content-type'], 'text/plain');
145+
assert.is(res.data, 'with space.txt\n');
146+
assert.is(res.statusCode, 200);
147+
} finally {
148+
server.close();
149+
}
150+
});
151+
126152
encode.run();
127153

128154
// ---

0 commit comments

Comments
 (0)