fix (backend): check URL properly

This commit is contained in:
naskya 2024-06-22 23:30:21 +09:00
parent aaa51e1bb4
commit 5a2d1c2010
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C
2 changed files with 8 additions and 4 deletions

View file

@ -87,14 +87,20 @@ export const paramDef = {
export default define(meta, paramDef, async (ps, me) => {
let user;
const isAdminOrModerator = me && (me.isAdmin || me.isModerator);
const isAdminOrModerator = me != null && (me.isAdmin || me.isModerator);
if (ps.userIds) {
if (ps.userIds.length === 0) {
return [];
}
const isUrl = ps.userIds[0].startsWith("http");
let isUrl = false;
try {
const url = new URL(ps.userIds[0]);
isUrl = ["http", "https"].includes(url.protocol);
} catch (_) {}
let users: User[];
if (isUrl) {
users = await Users.findBy(

View file

@ -360,10 +360,8 @@ import { getStaticImageUrl } from "@/scripts/get-static-image-url";
import number from "@/filters/number";
import { userPage } from "@/filters/user";
import { defaultStore } from "@/store";
import * as os from "@/os";
import { i18n } from "@/i18n";
import { isModerator, isSignedIn, me } from "@/me";
import { host } from "@/config";
import icon from "@/scripts/icon";
const XPhotos = defineAsyncComponent(() => import("./index.photos.vue"));