summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-06-22 18:32:59 -0400
committerChristopher Speller <crspeller@gmail.com>2016-06-22 18:32:59 -0400
commit6b22a8e81660881baa2ecb7d4cdd7b5abb2ff0b0 (patch)
tree5b3058d5d868ba034ed109114ba644ca876ede67 /webapp
parent2abc5a4a1a80e9c21d046c265f6bf46a63174066 (diff)
downloadchat-6b22a8e81660881baa2ecb7d4cdd7b5abb2ff0b0.tar.gz
chat-6b22a8e81660881baa2ecb7d4cdd7b5abb2ff0b0.tar.bz2
chat-6b22a8e81660881baa2ecb7d4cdd7b5abb2ff0b0.zip
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)
Diffstat (limited to 'webapp')
-rw-r--r--webapp/utils/text_formatting.jsx12
1 files changed, 8 insertions, 4 deletions
diff --git a/webapp/utils/text_formatting.jsx b/webapp/utils/text_formatting.jsx
index dbf18d722..7f4328dc9 100644
--- a/webapp/utils/text_formatting.jsx
+++ b/webapp/utils/text_formatting.jsx
@@ -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 />' : '');
});
-} \ No newline at end of file
+}