Normalize domain on /api/share

This commit is contained in:
Nikita Karamov 2023-03-27 21:24:58 +02:00
parent 23fdf5ab07
commit ce3e19626f
No known key found for this signature in database
GPG key ID: 41D6F71EE78E77CD

View file

@ -3,6 +3,7 @@
* Licensed under AGPL v3 or later * Licensed under AGPL v3 or later
*/ */
import { getUrlDomain } from "@scripts/util";
import type { APIRoute } from "astro"; import type { APIRoute } from "astro";
export const post: APIRoute = async ({ redirect, request, url }) => { export const post: APIRoute = async ({ redirect, request, url }) => {
@ -10,7 +11,7 @@ export const post: APIRoute = async ({ redirect, request, url }) => {
const text = (formData.get("text") as string) || ""; const text = (formData.get("text") as string) || "";
const instanceHost = const instanceHost =
(formData.get("instance") as string) || "mastodon.social"; getUrlDomain(formData.get("instance") as string) || "mastodon.social";
try { try {
const response = await fetch(new URL(`/api/detect/${instanceHost}`, url)); const response = await fetch(new URL(`/api/detect/${instanceHost}`, url));