summaryrefslogtreecommitdiff
path: root/lib/Paths.hs
diff options
context:
space:
mode:
authorstuebinm2021-11-19 01:29:28 +0100
committerstuebinm2021-11-19 01:29:28 +0100
commit321f4d5fa118515dcde522e1ad01ddd65741828b (patch)
treeaefb3ff2cb96d91059cbf3c16f6f7c81da145a5e /lib/Paths.hs
parent12025514261f524d7a4ded461709a7d151cc1b36 (diff)
add domain allow- and blocklists for weblinks
(these use a rather crude regex for parsing, which may be possible to side-step, and which should probably be replaced by something that was actually written while following the relevant rfc)
Diffstat (limited to 'lib/Paths.hs')
-rw-r--r--lib/Paths.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Paths.hs b/lib/Paths.hs
index af66e77..4082268 100644
--- a/lib/Paths.hs
+++ b/lib/Paths.hs
@@ -17,6 +17,16 @@ import Util (PrettyPrint (prettyprint))
data RelPath = Path Int Text (Maybe Text)
deriving (Show, Eq, Ord)
+
+extractDomain :: Text -> Maybe Text
+extractDomain url =
+ let (_,_,_,matches) = url =~ ("^https://([^/]+)/?.*$" :: Text) :: (Text,Text,Text,[Text])
+ in case matches of
+ [domain] -> Just domain
+ _ -> Nothing
+
+
+
-- | horrible regex parsing for filepaths that is hopefully kinda safe
parsePath :: Text -> Maybe RelPath
parsePath text =