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:
parent
ec7f3ce1c2
commit
31ddfd5a42
3 changed files with 16 additions and 2 deletions
|
@ -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()) {
|
||||
|
|
|
@ -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
0
std/http/testdata/test file.txt
vendored
Normal file
Loading…
Reference in a new issue