Handle /notes/ url too

pull/94/head
Lim Chee Aun 2023-04-03 10:05:57 +08:00
rodzic 3b100ad30f
commit 04b4101e55
1 zmienionych plików z 6 dodań i 1 usunięć

Wyświetl plik

@ -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;