From 04b4101e55763fb4e620e7449690eff53d54deb6 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Mon, 3 Apr 2023 10:05:57 +0800 Subject: [PATCH] Handle /notes/ url too --- src/pages/status.jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pages/status.jsx b/src/pages/status.jsx index be6aa0b8..922b25ff 100644 --- a/src/pages/status.jsx +++ b/src/pages/status.jsx @@ -955,14 +955,19 @@ function SubComments({ ); } +const statusRegex = /\/@([^@\/]+)@?([^\/]+)?\/([^\/]+)\/?$/i; +const statusNoteRegex = /\/notes\/([^\/]+)\/?$/i; function getInstanceStatusURL(url) { // Regex /:username/:id, where username = @username or @username@domain, id = anything - const statusRegex = /\/@([^@\/]+)@?([^\/]+)?\/([^\/]+)\/?$/i; const { hostname, pathname } = new URL(url); const [, username, domain, id] = pathname.match(statusRegex) || []; if (id) { return `/${hostname}/s/${id}`; } + const [, noteId] = pathname.match(statusNoteRegex) || []; + if (noteId) { + return `/${hostname}/s/${noteId}`; + } } export default StatusPage;