Merge branch 'tusooa/zwnj=nobrk' into 'master'

Do not break hashtag at zwnj

See merge request pleroma/elixir-libraries/linkify!51
This commit is contained in:
Haelwenn 2022-12-26 16:03:02 +00:00
commit d5ae88725a
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