mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-07-05 05:08:07 +02:00
fix(#205): fix encoded urls
This commit is contained in:
+6
-4
@@ -8,10 +8,12 @@ export const router = express.Router();
|
|||||||
router.get(
|
router.get(
|
||||||
"/:repoId/file/:path*",
|
"/:repoId/file/:path*",
|
||||||
async (req: express.Request, res: express.Response) => {
|
async (req: express.Request, res: express.Response) => {
|
||||||
const anonymizedPath = new URL(
|
const anonymizedPath = decodeURI(
|
||||||
req.url,
|
new URL(req.url, `${req.protocol}://${req.hostname}`).pathname.replace(
|
||||||
`${req.protocol}://${req.hostname}`
|
`/${req.params.repoId}/file/`,
|
||||||
).pathname.replace(`/${req.params.repoId}/file/`, "");
|
""
|
||||||
|
)
|
||||||
|
);
|
||||||
if (anonymizedPath.endsWith("/")) {
|
if (anonymizedPath.endsWith("/")) {
|
||||||
return handleError(
|
return handleError(
|
||||||
new AnonymousError("folder_not_supported", {
|
new AnonymousError("folder_not_supported", {
|
||||||
|
|||||||
Reference in New Issue
Block a user