mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-22 09:57:29 -07:00
[mastodon-client] improve mention regexes
This commit is contained in:
parent
c3dbca67e2
commit
7e27d979be
1 changed files with 4 additions and 4 deletions
|
@ -1522,11 +1522,11 @@ export default class Misskey implements MegalodonInterface {
|
||||||
)) {
|
)) {
|
||||||
if (m.acct == m.username)
|
if (m.acct == m.username)
|
||||||
status.content = status.content.replace(
|
status.content = status.content.replace(
|
||||||
`@${m.acct}@${this.baseUrlToHost(this.baseUrl)}`,
|
new RegExp(`(?<=^|\\s|>)@${m.acct}@${this.baseUrlToHost(this.baseUrl)}(?=[^a-zA-Z0-9]|$)`, 'g'),
|
||||||
`@${m.acct}`,
|
`@${m.acct}`,
|
||||||
);
|
);
|
||||||
status.content = status.content.replace(
|
status.content = status.content.replace(
|
||||||
`@${m.acct}`,
|
new RegExp(`(?<=^|\\s|>)@${m.acct}(?=[^a-zA-Z0-9]|$)`, 'g'),
|
||||||
`<a href="${m.url}" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@${m.acct}</a>`,
|
`<a href="${m.url}" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@${m.acct}</a>`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1542,7 +1542,7 @@ export default class Misskey implements MegalodonInterface {
|
||||||
if (text == undefined) return mentions;
|
if (text == undefined) return mentions;
|
||||||
|
|
||||||
const mentionMatch = text.matchAll(
|
const mentionMatch = text.matchAll(
|
||||||
/(?<=^|\s)@(?<user>.*?)(?:@(?<host>.*?)|)(?=\s|$)/g,
|
/(?<=^|\s)@(?<user>[a-zA-Z0-9_]+)(?:@(?<host>[a-zA-Z0-9-.]+\.[a-zA-Z0-9-]+)|)(?=[^a-zA-Z0-9]|$)/g,
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const m of mentionMatch) {
|
for (const m of mentionMatch) {
|
||||||
|
@ -2963,7 +2963,7 @@ export default class Misskey implements MegalodonInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const match = q.match(/^@(?<user>.*?)(?:@(?<host>.*?)|)$/);
|
const match = q.match(/^@(?<user>[a-zA-Z0-9_]+)(?:@(?<host>[a-zA-Z0-9-.]+\.[a-zA-Z0-9-]+)|)$/);
|
||||||
if (match) {
|
if (match) {
|
||||||
const lookupQuery = {
|
const lookupQuery = {
|
||||||
username: match.groups?.user,
|
username: match.groups?.user,
|
||||||
|
|
Loading…
Reference in a new issue