PLT-3211 Fixed search highlighting for hashtags starting with "#in", "#from", or "#channel" (#3400)
* Fixed clicking hashtags/@mentions adding a # to the url * Updated punctuation trimming regex for searching to better match the server * Fixed search term splitting to not break up hashtags starting with a search flag (in, from, etc)
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
2abc5a4a1a
Коммит
6b22a8e816
@@ -298,8 +298,8 @@ function autolinkHashtags(text, tokens) {
|
||||
return output.replace(/(^|\W)(#[a-zA-ZäöüÄÖÜß][a-zA-Z0-9äöüÄÖÜß.\-_]*)\b/g, replaceHashtagWithToken);
|
||||
}
|
||||
|
||||
const puncStart = /^[.,()&$!\[\]{}':;\\]+/;
|
||||
const puncEnd = /[.,()&$#!\[\]{}':;\\]+$/;
|
||||
const puncStart = /^[^a-zA-Z0-9#]+/;
|
||||
const puncEnd = /[^a-zA-Z0-9]+$/;
|
||||
|
||||
function parseSearchTerms(searchTerm) {
|
||||
let terms = [];
|
||||
@@ -334,7 +334,7 @@ function parseSearchTerms(searchTerm) {
|
||||
}
|
||||
|
||||
// capture any plain text up until the next quote or search flag
|
||||
captured = (/^.+?(?=\bin|\bfrom|\bchannel|"|$)/).exec(termString);
|
||||
captured = (/^.+?(?=\bin:|\bfrom:|\bchannel:|"|$)/).exec(termString);
|
||||
if (captured) {
|
||||
termString = termString.substring(captured[0].length);
|
||||
|
||||
@@ -446,8 +446,12 @@ export function handleClick(e) {
|
||||
const linkAttribute = e.target.getAttributeNode('data-link');
|
||||
|
||||
if (mentionAttribute) {
|
||||
e.preventDefault();
|
||||
|
||||
Utils.searchForTerm(mentionAttribute.value);
|
||||
} else if (hashtagAttribute) {
|
||||
e.preventDefault();
|
||||
|
||||
Utils.searchForTerm(hashtagAttribute.value);
|
||||
} else if (linkAttribute) {
|
||||
const MIDDLE_MOUSE_BUTTON = 1;
|
||||
@@ -465,4 +469,4 @@ function insertLongLinkWbr(test) {
|
||||
return test.replace(/\//g, (match, position, string) => {
|
||||
return match + ((/a[^>]*>[^<]*$/).test(string.substr(0, position)) ? '<wbr />' : '');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user