Do not break hashtag at zwnj

This commit is contained in:
tusooa 2022-12-25 20:37:01 -05:00
parent 123dbb0fd6
commit 3599ccf759
No known key found for this signature in database
GPG key ID: 7B467EDE43A08224
2 changed files with 13 additions and 1 deletions

View file

@ -15,7 +15,7 @@ defmodule Linkify.Parser do
@get_scheme_host ~r{^\W*(?<scheme>https?:\/\/)?(?:[^@\n]+\\w@)?(?<host>[^:#~\/\n?]+)}u
@match_hashtag ~r/^(?<tag>\#[[:word:]_]*[[:alpha:]_·][[:word:]_·\p{M}]*)/u
@match_hashtag ~r/^(?<tag>\#[[:word:]_]*[[:alpha:]_·\x{200c}][[:word:]_·\p{M}\x{200c}]*)/u
@match_skipped_tag ~r/^(?<tag>(a|code|pre)).*>*/

View file

@ -555,6 +555,18 @@ defmodule LinkifyTest do
hashtag_prefix: "https://example.com/tag/"
) == expected
end
test "ZWNJ does not break up hashtags" do
text = "#ساٴين‌س"
expected = "<a href=\"https://example.com/tag/ساٴين‌س\">#ساٴين‌س</a>"
assert Linkify.link(text,
rel: false,
hashtag: true,
hashtag_prefix: "https://example.com/tag/"
) == expected
end
end
describe "links" do