* [Glitch] Change search pop-out in web UI Port2b11376411
to glitch-soc Signed-off-by: Plastikmensch <plastikmensch@users.noreply.github.com> * [Glitch] Change logo version in header based on screen size in web UI Port remaining change from6028d047b9
to glitch-soc Signed-off-by: Plastikmensch <plastikmensch@users.noreply.github.com> * Rename `hashtags.js` to `hashtags.ts` and apply code style changes Apply changes frome38b391940
(rename to ts),51b83ed195
(code style change),73b64b8917
(additional code style change) Signed-off-by: Plastikmensch <plastikmensch@users.noreply.github.com> * Remove strings for old search Signed-off-by: Plastikmensch <plastikmensch@users.noreply.github.com> --------- Signed-off-by: Plastikmensch <plastikmensch@users.noreply.github.com>
29 lines
879 B
TypeScript
29 lines
879 B
TypeScript
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();
|