feat(pastes): add support for url pastes

Signed-off-by: SphericalKat <amolele@gmail.com>
This commit is contained in:
sphericalkat committed 2021-08-13 07:46:10 +05:30
1 parent 1b54edf7b3
commit 750d62cc73
5 files changed
+37 -6

No files matched your search

+10 -1
View File
@@ -16,4 +16,13 @@ defmodule Ketbin.Pastes.Utils do
Enum.map(0..length, fn i -> if Integer.mod(i, 2) == random, do: rand_consonant(), else: rand_vowel() end)
|> List.to_string
end
end
def is_url?(url) do
try do
uri = URI.parse(url)
uri.scheme != nil && uri.host =~ "." && Enum.member?(["https", "http"], uri.scheme)
rescue
FunctionClauseError -> false
end
end
end