fix: 🐛 double-slash in proxy url

This commit is contained in:
ThatOneCalculator 2023-08-06 12:30:00 -07:00
parent 33b4b1d18c
commit 2448b2ce99
No known key found for this signature in database
GPG Key ID: 8703CACD01000000

View File

@ -14,13 +14,15 @@ import { serverLogger } from "../index.js";
import { isMimeImage } from "@/misc/is-mime-image.js"; import { isMimeImage } from "@/misc/is-mime-image.js";
export async function proxyMedia(ctx: Koa.Context) { 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") { if (typeof url !== "string") {
ctx.status = 400; ctx.status = 400;
return; return;
} }
url = url.replace("//", "/");
const { hostname } = new URL(url); const { hostname } = new URL(url);
let resolvedIps; let resolvedIps;
try { try {