From 2448b2ce99d2f921e58e960fd75aabab62fb80c5 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Sun, 6 Aug 2023 12:30:00 -0700 Subject: [PATCH] fix: :bug: double-slash in proxy url --- packages/backend/src/server/proxy/proxy-media.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/server/proxy/proxy-media.ts b/packages/backend/src/server/proxy/proxy-media.ts index b3bb031244..ed607daa0e 100644 --- a/packages/backend/src/server/proxy/proxy-media.ts +++ b/packages/backend/src/server/proxy/proxy-media.ts @@ -14,13 +14,15 @@ import { serverLogger } from "../index.js"; import { isMimeImage } from "@/misc/is-mime-image.js"; export async function proxyMedia(ctx: Koa.Context) { - const url = "url" in ctx.query ? ctx.query.url : `https://${ctx.params.url}`; + let url = "url" in ctx.query ? ctx.query.url : `https://${ctx.params.url}`; if (typeof url !== "string") { ctx.status = 400; return; } + url = url.replace("//", "/"); + const { hostname } = new URL(url); let resolvedIps; try {