Fix hashtags incorrectly displayed inside URLs (#692)

When a URL contains a # fragment (e.g. https://example.com/page#section),
the hashtag regex matches the fragment as a hashtag. The overlap removal
logic already removes hashtags overlapping geohashes, and geohashes
overlapping URLs, but did not remove hashtags overlapping URLs. Add the
missing overlapsUrl check to the hashtag condition.
This commit is contained in:
5t34k 2026-06-26 06:04:23 +10:00 committed by GitHub
parent 648ae6c1dd
commit 34a6f37041
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -398,10 +398,10 @@ private fun appendIOSFormattedContent(
val iterator = allMatches.listIterator()
while (iterator.hasNext()) {
val (range, type) = iterator.next()
// Remove generic hashtags that overlap with geohashes, and geohashes that overlap with URLs
// Remove generic hashtags that overlap with geohashes or URLs, and geohashes that overlap with URLs
val overlapsGeo = geoRanges.any { rangesOverlap(range, it) }
val overlapsUrl = urlRanges.any { rangesOverlap(range, it) }
if ((type == "hashtag" && overlapsGeo) || (type == "geohash" && overlapsUrl)) iterator.remove()
if ((type == "hashtag" && (overlapsGeo || overlapsUrl)) || (type == "geohash" && overlapsUrl)) iterator.remove()
}
}