fix(#205): fix encoded urls

This commit is contained in:
tdurieux
2023-05-02 18:31:57 +02:00
parent f1d6e4534d
commit e5ffad6364

View File

@@ -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", {