fix: 🐛 double-slash in proxy url
This commit is contained in:
parent
33b4b1d18c
commit
2448b2ce99
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user