Merge branch 'tusooa/doubledotlink' into 'master'
Allow double dots in links See merge request pleroma/elixir-libraries/linkify!52
This commit is contained in:
commit
1e612ac3a3
2 changed files with 14 additions and 1 deletions
|
@ -301,7 +301,15 @@ defmodule Linkify.Parser do
|
|||
end
|
||||
end
|
||||
|
||||
defp valid_url?(url), do: !Regex.match?(@invalid_url, url)
|
||||
defp valid_url?(url) do
|
||||
with {_, [scheme]} <- {:regex, Regex.run(@get_scheme_host, url, capture: [:scheme])},
|
||||
true <- scheme == "" do
|
||||
!Regex.match?(@invalid_url, url)
|
||||
else
|
||||
_ ->
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Validates a URL's TLD. Returns a boolean.
|
||||
|
|
|
@ -226,6 +226,11 @@ defmodule Linkify.ParserTest do
|
|||
assert parse(text) == "(check out <a href=\"http://google.com\">google.com</a>)"
|
||||
end
|
||||
|
||||
test "double dot in link is allowed" do
|
||||
text = "https://example.to/something..mp3"
|
||||
assert parse(text) == "<a href=\"#{text}\">#{text}</a>"
|
||||
end
|
||||
|
||||
test "do not link urls" do
|
||||
text = "google.com"
|
||||
assert parse(text, url: false) == text
|
||||
|
|
Loading…
Reference in a new issue