Link detection too greedy
bb opened this issue · comments
The link detection in the FieldValue component is too greedy. The regular expression in
mini-dashboard/src/components/Results/Hit.js
Line 103 in a71bf04
^
before https and maybe also check if there are only URL-Characters until the end. Out of my head, a naive approach might be match(/^https?:\/\/[^\s]+$/)
.
Example document:
[{
"id": 1,
"description": "When I need a fast search engine, I go to https://www.meilisearch.com/"
},
{
"id": 2,
"description": "https://www.meilisearch.com/ is the place to go when you need instant search."
}]
Actual
Both documents have their description field currently rendered as a full link, i.e.
<a href="When I need a fast search engine, I go to https://www.meilisearch.com/"
target="_blank" rel="noreferrer" class="sc-pNWdM kMtlSK sc-iklJeh fNZzln">
<span class="sc-gtsrHT kSJQSN">
<span>When I need a</span>
<mark>fast search engine</mark>
<span> ....
Expected
I expect the description of neither of the example documents to be rendered as a link.
Rendering a link inside is fine, but not the whole field.
Thanks, Benjamin for this feedback. Indeed, we put the field value in a Link component. This Link component must only surround the link identified by the pattern. 🤓