Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/decoding uri #3187

Merged
merged 4 commits into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions std/http/file_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,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()) {
Expand Down
14 changes: 14 additions & 0 deletions std/http/file_server_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,17 @@ test(async function serveFallback(): Promise<void> {
killFileServer();
}
});

test(async function serveFallback(): Promise<void> {
await startFileServer();
try {
const res = await fetch(
"https://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();
}
});
Empty file added std/http/testdata/test file.txt
Empty file.