Skip to content

Commit

Permalink
chore: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeed committed Apr 24, 2023
1 parent 79dd4bd commit ef038a6
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions tests/sirv.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ encode('should work when the request path contains encoded characters :: prod',
}
});

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

try {
Expand All @@ -136,7 +136,7 @@ encode(`should work when the request path contains space encoded :: dev`, async
}
});

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

try {
Expand All @@ -149,6 +149,34 @@ encode(`should work when the request path contains space encoded :: prod`, async
}
});

encode('should not treat "/foo%2Fbar.txt" the same as "/foo.bar.txt" path :: dev', async () => {
let server = utils.http({ dev: true });

try {
let res1 = await server.send('GET', '/about/index.htm');
assert.is(res1.statusCode, 200);

let res2 = await server.send('GET', '/about%2Findex.htm').catch(r => r);
assert.is(res2.statusCode, 404);
} finally {
server.close();
}
});

encode('should not treat "/foo%2Fbar.txt" the same as "/foo.bar.txt" path :: prod', async () => {
let server = utils.http({ dev: false });

try {
let res1 = await server.send('GET', '/about/index.htm');
assert.is(res1.statusCode, 200);

let res2 = await server.send('GET', '/about%2Findex.htm').catch(r => r);
assert.is(res2.statusCode, 404);
} finally {
server.close();
}
});

encode.run();

// ---
Expand Down

0 comments on commit ef038a6

Please sign in to comment.