mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-30 23:08:00 +01:00
14 lines
338 B
Elixir
14 lines
338 B
Elixir
|
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
|