chore (backend): use literals and consts

This commit is contained in:
naskya 2024-05-16 04:22:23 +09:00
parent 101e50926b
commit 0de54e02f8
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C
2 changed files with 18 additions and 19 deletions

View file

@ -149,7 +149,7 @@ router.get<{ Params: { path: string } }>("/emoji/:path(.*)", async (ctx) => {
return; return;
} }
let url = new URL(`${config.mediaProxy || config.url + "/proxy"}/emoji.webp`); const url = new URL(`${config.mediaProxy || `${config.url}/proxy`}/emoji.webp`);
// || emoji.originalUrl してるのは後方互換性のため // || emoji.originalUrl してるのは後方互換性のため
url.searchParams.append("url", emoji.publicUrl || emoji.originalUrl); url.searchParams.append("url", emoji.publicUrl || emoji.originalUrl);
url.searchParams.append("emoji", "1"); url.searchParams.append("emoji", "1");
@ -370,9 +370,7 @@ const getFeed = async (
}; };
// As the /@user[.json|.rss|.atom]/sub endpoint is complicated, we will use a regex to switch between them. // As the /@user[.json|.rss|.atom]/sub endpoint is complicated, we will use a regex to switch between them.
const reUser = new RegExp( const reUser = /^\/@(?<user>[^\/]+?)(?:.(?<feed>json|rss|atom)(?:\?[^\/]*)?)?(?:\/(?<sub>[^\/]+))?$/;
"^/@(?<user>[^/]+?)(?:.(?<feed>json|rss|atom)(?:\\?[^/]*)?)?(?:/(?<sub>[^/]+))?$",
);
router.get(reUser, async (ctx, next) => { router.get(reUser, async (ctx, next) => {
const groups = reUser.exec(ctx.originalUrl)?.groups; const groups = reUser.exec(ctx.originalUrl)?.groups;
if (!groups) { if (!groups) {

View file

@ -5,7 +5,8 @@ import { config } from "@/config.js";
const manifest = { const manifest = {
short_name: "Firefish", short_name: "Firefish",
name: "Firefish", name: "Firefish",
description: "An open source, decentralized social media platform that's free forever!", description:
"An open source, decentralized social media platform that's free forever!",
start_url: "/", start_url: "/",
scope: "/", scope: "/",
display: "standalone", display: "standalone",
@ -17,34 +18,34 @@ const manifest = {
src: "/static-assets/icons/192.png", src: "/static-assets/icons/192.png",
sizes: "192x192", sizes: "192x192",
type: "image/png", type: "image/png",
purpose: "any" purpose: "any",
}, },
{ {
src: "/static-assets/icons/512.png", src: "/static-assets/icons/512.png",
sizes: "512x512", sizes: "512x512",
type: "image/png", type: "image/png",
purpose: "any" purpose: "any",
}, },
{ {
src: "/static-assets/icons/maskable.png", src: "/static-assets/icons/maskable.png",
sizes: "512x512", sizes: "512x512",
type: "image/png", type: "image/png",
purpose: "maskable" purpose: "maskable",
}, },
{ {
src: "/static-assets/icons/monochrome.png", src: "/static-assets/icons/monochrome.png",
sizes: "512x512", sizes: "512x512",
type: "image/png", type: "image/png",
purpose: "monochrome" purpose: "monochrome",
} },
], ],
share_target: { share_target: {
action: "/share/", action: "/share/",
params: { params: {
title: "title", title: "title",
text: "text", text: "text",
url: "url" url: "url",
} },
}, },
screenshots: [ screenshots: [
{ {
@ -52,28 +53,28 @@ const manifest = {
sizes: "1080x2340", sizes: "1080x2340",
type: "image/webp", type: "image/webp",
platform: "narrow", platform: "narrow",
label: "Profile page" label: "Profile page",
}, },
{ {
src: "/static-assets/screenshots/2.webp", src: "/static-assets/screenshots/2.webp",
sizes: "1080x2340", sizes: "1080x2340",
type: "image/webp", type: "image/webp",
platform: "narrow", platform: "narrow",
label: "Posts" label: "Posts",
} },
], ],
shortcuts: [ shortcuts: [
{ {
name: "Notifications", name: "Notifications",
short_name: "Notifs", short_name: "Notifs",
url: "/my/notifications" url: "/my/notifications",
}, },
{ {
name: "Chats", name: "Chats",
url: "/my/messaging" url: "/my/messaging",
} },
], ],
categories: ["social"] categories: ["social"],
}; };
export const manifestHandler = async (ctx: Koa.Context) => { export const manifestHandler = async (ctx: Koa.Context) => {