New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX]: Broken links in search #23309
base: develop
Are you sure you want to change the base?
Conversation
Added a more precise regex to check and replace the searched text with a highlight. (Ignoring the links in href which was causing the issue)
What's the difference with #20878 ? A lot of issues are referencing that problem, and now we have 2 PRs, but still no answers from RocketChat maintainers.... |
I am sorry I didn't see that PR, I guess it's better maintained and I should close this one |
No problem ! It hasn't been updated for a while though... 😅 |
Rather than trying to fix the regexp, wouldn't it be more advisable to accept the fact highlighting cannot be simply done with regular expressions ? See this SO question and answer : https://stackoverflow.com/a/8193700/2955802 That handle the problem stated here, which is not highlighting everything that is inside tags. |
I don't get your point, we were able to fix that highlighting issue, using (not only, right) better regexes 🤷♂️ Wether it is that PR #23309 or mine #20878 . The regex/code just need to be upgraded for any new/specific element that can break highlighting |
Can be closed, fixed by #20878 (merged) 😉 |
Added a more precise regex to check and replace the searched text with a highlight. (Ignoring the links in href which was causing the issue)
Proposed changes (including videos or screenshots)
The following image is taken from the issue #23285.
As the user mentioned the
<a>
tag doesn't seem to get the correct URL in thehref
attribute.The reason being that if a searched text is present in the search result it gets replaced by
<mark>text<mark>
. But this also affectes the attributes. For instance, if we searched forgoogle.com
,href="google.com"
would becomehref="<mark>google.com</mark>"
, which results in wrong destination.This was fixed using a more narrow regex search. Here I look for only those matches which does not come between
href="
and"
Following this change the URL points to the right link.
Issue(s)
#23285
Steps to test or reproduce
Reproduction steps mentioned in the issue
Further comments
My first PR, please suggest better approaches, if any.