Change search pop-out in web UI (#24305)
This commit is contained in:
parent
46483ae849
commit
2b11376411
10 changed files with 447 additions and 91 deletions
47
app/javascript/mastodon/utils/hashtags.js
Normal file
47
app/javascript/mastodon/utils/hashtags.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
const HASHTAG_SEPARATORS = '_\\u00b7\\u200c';
|
||||
const ALPHA = '\\p{L}\\p{M}';
|
||||
const WORD = '\\p{L}\\p{M}\\p{N}\\p{Pc}';
|
||||
|
||||
const buildHashtagPatternRegex = () => {
|
||||
try {
|
||||
return new RegExp(
|
||||
'(?:^|[^\\/\\)\\w])#((' +
|
||||
'[' + WORD + '_]' +
|
||||
'[' + WORD + HASHTAG_SEPARATORS + ']*' +
|
||||
'[' + ALPHA + HASHTAG_SEPARATORS + ']' +
|
||||
'[' + WORD + HASHTAG_SEPARATORS +']*' +
|
||||
'[' + WORD + '_]' +
|
||||
')|(' +
|
||||
'[' + WORD + '_]*' +
|
||||
'[' + ALPHA + ']' +
|
||||
'[' + WORD + '_]*' +
|
||||
'))', 'iu',
|
||||
);
|
||||
} catch {
|
||||
return /(?:^|[^/)\w])#(\w*[a-zA-Z·]\w*)/i;
|
||||
}
|
||||
};
|
||||
|
||||
const buildHashtagRegex = () => {
|
||||
try {
|
||||
return new RegExp(
|
||||
'^((' +
|
||||
'[' + WORD + '_]' +
|
||||
'[' + WORD + HASHTAG_SEPARATORS + ']*' +
|
||||
'[' + ALPHA + HASHTAG_SEPARATORS + ']' +
|
||||
'[' + WORD + HASHTAG_SEPARATORS +']*' +
|
||||
'[' + WORD + '_]' +
|
||||
')|(' +
|
||||
'[' + WORD + '_]*' +
|
||||
'[' + ALPHA + ']' +
|
||||
'[' + WORD + '_]*' +
|
||||
'))$', 'iu',
|
||||
);
|
||||
} catch {
|
||||
return /^(\w*[a-zA-Z·]\w*)$/i;
|
||||
}
|
||||
};
|
||||
|
||||
export const HASHTAG_PATTERN_REGEX = buildHashtagPatternRegex();
|
||||
|
||||
export const HASHTAG_REGEX = buildHashtagRegex();
|
Loading…
Add table
Add a link
Reference in a new issue