1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-14 10:01:51 -05:00

fix: decoding uri in file_server (#3187)

This commit is contained in:
AleksandrukTad 2019-12-10 12:11:55 +00:00 committed by Ry Dahl
parent ec7f3ce1c2
commit 31ddfd5a42
3 changed files with 16 additions and 2 deletions

View file

@ -285,10 +285,10 @@ listenAndServe(
addr,
async (req): Promise<void> => {
const normalizedUrl = posix.normalize(req.url);
const fsPath = posix.join(target, normalizedUrl);
const decodedUrl = decodeURIComponent(normalizedUrl);
const fsPath = posix.join(target, decodedUrl);
let response: Response;
try {
const info = await stat(fsPath);
if (info.isDirectory()) {

View file

@ -79,3 +79,17 @@ test(async function serveFallback(): Promise<void> {
killFileServer();
}
});
test(async function serveFallback(): Promise<void> {
await startFileServer();
try {
const res = await fetch(
"http://localhost:4500/http/testdata/test%20file.txt"
);
assert(res.headers.has("access-control-allow-origin"));
assert(res.headers.has("access-control-allow-headers"));
assertEquals(res.status, 200);
} finally {
killFileServer();
}
});

0
std/http/testdata/test file.txt vendored Normal file
View file