philomena/lib/textile/url_lexer.ex

14 lines
338 B
Elixir
Raw Normal View History

2019-11-04 00:58:11 +01:00
defmodule Textile.UrlLexer do
import NimbleParsec
def url_ending_in(ending_sequence) do
protocol =
choice([
string("/"), string("https://"), string("http://"), string("data:image/")
])
protocol
|> repeat(lookahead_not(ending_sequence) |> utf8_char([]))
|> reduce({List, :to_string, []})
end
end