diff --git a/lib/linkify/parser.ex b/lib/linkify/parser.ex
index 71e5ca8..7011d10 100644
--- a/lib/linkify/parser.ex
+++ b/lib/linkify/parser.ex
@@ -300,7 +300,7 @@ defmodule Linkify.Parser do
opts[:validate_tld] == false ->
true
- ip?(host) ->
+ scheme != "" && ip?(host) ->
true
# don't validate if scheme is present
diff --git a/test/linkify_test.exs b/test/linkify_test.exs
index fdc04e5..09214de 100644
--- a/test/linkify_test.exs
+++ b/test/linkify_test.exs
@@ -768,10 +768,14 @@ defmodule LinkifyTest do
assert Linkify.link(text) == expected
end
- test "IPv4 is linked" do
+ test "IPv4 is linked only with scheme" do
text = "1.1.1.1"
- expected = "1.1.1.1"
+ assert Linkify.link(text) == text
+
+ text = "http://1.1.1.1"
+
+ expected = "http://1.1.1.1"
assert Linkify.link(text) == expected
end
diff --git a/test/parser_test.exs b/test/parser_test.exs
index cd00df1..c7298d2 100644
--- a/test/parser_test.exs
+++ b/test/parser_test.exs
@@ -275,9 +275,7 @@ defmodule Linkify.ParserTest do
"example.com",
"example.ca",
"example.tv",
- "example.com:999?one=one",
- "255.255.255.255",
- "255.255.255.255:3000?one=1&two=2"
+ "example.com:999?one=one"
]
def invalid_non_scheme_urls,
@@ -285,7 +283,9 @@ defmodule Linkify.ParserTest do
"invalid.com/perl.cgi?key= | web-site.com/cgi-bin/perl.cgi?key1=value1&key2",
"invalid.",
"hi..there",
- "555.555.5555"
+ "555.555.5555",
+ "255.255.255.255",
+ "255.255.255.255:3000?one=1&two=2"
]
def custom_tld_scheme_urls,