From ef6f7c0e08e01dd66d7e02ee66d321139ad1b308 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anselm=20Sch=C3=BCler?= Date: Mon, 5 Jul 2021 20:12:27 +0200 Subject: [PATCH] Strip trailing slashes from path in send Adds import of sep from std/path Attempt to fix #356 --- send.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/send.ts b/send.ts index bfd4f041..96976d69 100644 --- a/send.ts +++ b/send.ts @@ -17,7 +17,7 @@ import { } from "./deps.ts"; import { ifRange, MultiPartStream, parseRange } from "./range.ts"; import type { Response } from "./response.ts"; -import { decodeComponent, getBoundary, resolvePath } from "./util.ts"; +import { decodeComponent, getBoundary, resolvePath, sep } from "./util.ts"; const MAXBUFFER_DEFAULT = 1_048_576; // 1MiB; const BOUNDARY = getBoundary(); @@ -183,7 +183,7 @@ export async function send( root, } = options; const trailingSlash = path[path.length - 1] === "/"; - path = decodeComponent(path.substr(parse(path).root.length)); + path = decodeComponent(path.substr(parse(path).root.length)).replace(new RegExp(`^${sep}+`), sep); if (index && trailingSlash) { path += index; }