mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-22 21:59:22 +01:00
Handle /notes/ url too
This commit is contained in:
parent
3b100ad30f
commit
04b4101e55
1 changed files with 6 additions and 1 deletions
|
@ -955,14 +955,19 @@ function SubComments({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const statusRegex = /\/@([^@\/]+)@?([^\/]+)?\/([^\/]+)\/?$/i;
|
||||||
|
const statusNoteRegex = /\/notes\/([^\/]+)\/?$/i;
|
||||||
function getInstanceStatusURL(url) {
|
function getInstanceStatusURL(url) {
|
||||||
// Regex /:username/:id, where username = @username or @username@domain, id = anything
|
// Regex /:username/:id, where username = @username or @username@domain, id = anything
|
||||||
const statusRegex = /\/@([^@\/]+)@?([^\/]+)?\/([^\/]+)\/?$/i;
|
|
||||||
const { hostname, pathname } = new URL(url);
|
const { hostname, pathname } = new URL(url);
|
||||||
const [, username, domain, id] = pathname.match(statusRegex) || [];
|
const [, username, domain, id] = pathname.match(statusRegex) || [];
|
||||||
if (id) {
|
if (id) {
|
||||||
return `/${hostname}/s/${id}`;
|
return `/${hostname}/s/${id}`;
|
||||||
}
|
}
|
||||||
|
const [, noteId] = pathname.match(statusNoteRegex) || [];
|
||||||
|
if (noteId) {
|
||||||
|
return `/${hostname}/s/${noteId}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default StatusPage;
|
export default StatusPage;
|
||||||
|
|
Loading…
Reference in a new issue