A feature that auto-links matching keywords inside page text starts linking letters buried in the middle of unrelated words, not just genuine whole-word matches.
⚡ Quick Fix (TL;DR)
The Culprit: A plain substring search (JavaScript's indexOf, or an equivalent) matches a short term anywhere it appears as a sequence of characters, even mid-word. Confirmed directly: a dictionary term "URL" matched inside the unrelated word "curly," and "DOM" matched inside "domain" – both false positives from treating any character match as a hit, with no awareness of word boundaries.
The Fix: Match only whole-word occurrences using a word-boundary-anchored regular expression instead of plain substring search.
// Wrong — plain substring search, matches mid-word:
text.toLowerCase().indexOf(term.toLowerCase())
// Right — word-boundary regex, whole-word matches only:
var re = new RegExp("b" + term + "b", "i");
var match = re.exec(text);Tagged in :
More from the field
Bisect to an Empty Baseline Before Trusting Any Single Theory
.
Multiple plausible-sounding theories for a bug each turned out to be wrong when actually tested – time was spent building fixes…
A Security Dashboard’s Activity Log Can Lag a Full Day Behind Real Time
.
Trying to check a security tool’s activity log for an event that had just happened showed nothing at all.