From e5ffad63641fcc6b75e61f7fa8f99c940784ddb7 Mon Sep 17 00:00:00 2001 From: tdurieux Date: Tue, 2 May 2023 18:31:57 +0200 Subject: [PATCH] fix(#205): fix encoded urls --- src/routes/file.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/routes/file.ts b/src/routes/file.ts index a8116d2..36cfd1b 100644 --- a/src/routes/file.ts +++ b/src/routes/file.ts @@ -8,10 +8,12 @@ export const router = express.Router(); router.get( "/:repoId/file/:path*", async (req: express.Request, res: express.Response) => { - const anonymizedPath = new URL( - req.url, - `${req.protocol}://${req.hostname}` - ).pathname.replace(`/${req.params.repoId}/file/`, ""); + const anonymizedPath = decodeURI( + new URL(req.url, `${req.protocol}://${req.hostname}`).pathname.replace( + `/${req.params.repoId}/file/`, + "" + ) + ); if (anonymizedPath.endsWith("/")) { return handleError( new AnonymousError("folder_not_supported", {