summaryrefslogtreecommitdiff
path: root/std/http/file_server.ts
diff options
context:
space:
mode:
Diffstat (limited to 'std/http/file_server.ts')
-rwxr-xr-xstd/http/file_server.ts12
1 files changed, 9 insertions, 3 deletions
diff --git a/std/http/file_server.ts b/std/http/file_server.ts
index acf272764..d71b9ad53 100755
--- a/std/http/file_server.ts
+++ b/std/http/file_server.ts
@@ -301,9 +301,15 @@ function html(strings: TemplateStringsArray, ...values: unknown[]): string {
listenAndServe(
addr,
async (req): Promise<void> => {
- const normalizedUrl = posix.normalize(req.url);
- const decodedUrl = decodeURIComponent(normalizedUrl);
- const fsPath = posix.join(target, decodedUrl);
+ let normalizedUrl = posix.normalize(req.url);
+ try {
+ normalizedUrl = decodeURIComponent(normalizedUrl);
+ } catch (e) {
+ if (!(e instanceof URIError)) {
+ throw e;
+ }
+ }
+ const fsPath = posix.join(target, normalizedUrl);
let response: Response;
try {