diff --git a/lib/linkify/builder.ex b/lib/linkify/builder.ex
index 9b3f1b0..385f6b3 100644
--- a/lib/linkify/builder.ex
+++ b/lib/linkify/builder.ex
@@ -53,7 +53,7 @@ defmodule Linkify.Builder do
defp format_url(attrs, url, opts) do
url =
url
- |> strip_prefix(Map.get(opts, :strip_prefix, true))
+ |> strip_prefix(Map.get(opts, :strip_prefix, false))
|> truncate(Map.get(opts, :truncate, false))
attrs = format_attrs(attrs)
diff --git a/mix.exs b/mix.exs
index 1d5959c..a24629e 100644
--- a/mix.exs
+++ b/mix.exs
@@ -1,7 +1,7 @@
defmodule Linkify.Mixfile do
use Mix.Project
- @version "0.1.0"
+ @version "0.1.1"
def project do
[
diff --git a/test/linkify_test.exs b/test/linkify_test.exs
index c50aace..9ec7c43 100644
--- a/test/linkify_test.exs
+++ b/test/linkify_test.exs
@@ -16,7 +16,7 @@ defmodule LinkifyTest do
text = "hello google.com https://ddg.com user@email.com irc:///mIRC"
expected =
- "hello google.com ddg.com user@email.com irc:///mIRC"
+ "hello google.com https://ddg.com user@email.com irc:///mIRC"
assert Linkify.link(text,
email: true,
@@ -244,40 +244,53 @@ defmodule LinkifyTest do
text = "Hey, check out http://www.youtube.com/watch?v=8Zg1-TufF%20zY?x=1&y=2#blabla ."
expected =
- "Hey, check out youtube.com/watch?v=8Zg1-TufF%20zY?x=1&y=2#blabla ."
+ "Hey, check out http://www.youtube.com/watch?v=8Zg1-TufF%20zY?x=1&y=2#blabla ."
assert Linkify.link(text, new_window: true) == expected
# no scheme
text = "Hey, check out www.youtube.com/watch?v=8Zg1-TufF%20zY?x=1&y=2#blabla ."
+
+ expected =
+ "Hey, check out www.youtube.com/watch?v=8Zg1-TufF%20zY?x=1&y=2#blabla ."
+
assert Linkify.link(text, new_window: true) == expected
end
test "turn urls with schema into urls" do
text = "📌https://google.com"
- expected = "📌google.com"
+ expected = "📌https://google.com"
assert Linkify.link(text, rel: false) == expected
end
+ test "skip prefix" do
+ assert Linkify.link("http://google.com", strip_prefix: true) ==
+ "google.com"
+
+ assert Linkify.link("http://www.google.com", strip_prefix: true) ==
+ "google.com"
+ end
+
test "hostname/@user" do
text = "https://example.com/@user"
- expected = "example.com/@user"
+ expected =
+ "https://example.com/@user"
assert Linkify.link(text, new_window: true) == expected
text = "https://example.com:4000/@user"
expected =
- "example.com:4000/@user"
+ "https://example.com:4000/@user"
assert Linkify.link(text, new_window: true) == expected
text = "https://example.com:4000/@user"
expected =
- "example.com:4000/@user"
+ "https://example.com:4000/@user"
assert Linkify.link(text, new_window: true) == expected
@@ -287,28 +300,28 @@ defmodule LinkifyTest do
text = "http://www.cs.vu.nl/~ast/intel/"
- expected = "cs.vu.nl/~ast/intel/"
+ expected = "http://www.cs.vu.nl/~ast/intel/"
assert Linkify.link(text) == expected
text = "https://forum.zdoom.org/viewtopic.php?f=44&t=57087"
expected =
- "forum.zdoom.org/viewtopic.php?f=44&t=57087"
+ "https://forum.zdoom.org/viewtopic.php?f=44&t=57087"
assert Linkify.link(text) == expected
text = "https://en.wikipedia.org/wiki/Sophia_(Gnosticism)#Mythos_of_the_soul"
expected =
- "en.wikipedia.org/wiki/Sophia_(Gnosticism)#Mythos_of_the_soul"
+ "https://en.wikipedia.org/wiki/Sophia_(Gnosticism)#Mythos_of_the_soul"
assert Linkify.link(text) == expected
text = "https://en.wikipedia.org/wiki/Duff's_device"
expected =
- "en.wikipedia.org/wiki/Duff's_device"
+ "https://en.wikipedia.org/wiki/Duff's_device"
assert Linkify.link(text) == expected
end
@@ -354,7 +367,7 @@ defmodule LinkifyTest do
test "parse with scheme" do
text = "https://google.com"
- expected = "google.com"
+ expected = "https://google.com"
assert Linkify.link(text) == expected
end
@@ -368,7 +381,7 @@ defmodule LinkifyTest do
text = "this url https://google.foobar.com/ has valid TLD"
expected =
- "this url google.foobar.com/ has valid TLD"
+ "this url https://google.foobar.com/ has valid TLD"
assert Linkify.link(text) == expected
end
@@ -389,7 +402,7 @@ defmodule LinkifyTest do
text = "this url http://google.foobar.com/ has valid TLD"
expected =
- "this url google.foobar.com/ has valid TLD"
+ "this url http://google.foobar.com/ has valid TLD"
assert Linkify.link(text) == expected
diff --git a/test/parser_test.exs b/test/parser_test.exs
index 9b74235..8aa7ed6 100644
--- a/test/parser_test.exs
+++ b/test/parser_test.exs
@@ -159,7 +159,7 @@ defmodule Linkify.ParserTest do
text = " foo (https://example.com/path/folder/), bar"
expected =
- " foo (example.com/path/folder/), bar"
+ " foo (https://example.com/path/folder/), bar"
assert parse(text, class: false, rel: false, scheme: true) == expected