summaryrefslogtreecommitdiff
path: root/lib/Paths.hs
diff options
context:
space:
mode:
authorSven G. Brönstrup2021-12-20 00:32:44 +0100
committerSven G. Brönstrup2021-12-20 00:32:44 +0100
commit7e65bc46f66c6073c998cfaea2a9644cbb9b896a (patch)
treea0d932cc4c26b3c3e63b61c7e39df4b3c816fb94 /lib/Paths.hs
parent8f5af0492e7a82192d1fafda3d2c74421af4354d (diff)
parent5060f68b9728bf94818ee985c16c25511f248143 (diff)
Merge branch 'main' into extended-scripts
Diffstat (limited to 'lib/Paths.hs')
-rw-r--r--lib/Paths.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/Paths.hs b/lib/Paths.hs
index f72874f..d2861eb 100644
--- a/lib/Paths.hs
+++ b/lib/Paths.hs
@@ -20,12 +20,18 @@ data RelPath = Path Int Text (Maybe Text)
-data PathResult = OkRelPath RelPath | AbsolutePath | NotAPath | UnderscoreMapLink | AtMapLink
+data PathResult = OkRelPath RelPath
+ | AbsolutePath
+ | NotAPath
+ | UnderscoreMapLink
+ | AtMapLink
+ | PathVarsDisallowed
-- | horrible regex parsing for filepaths that is hopefully kinda safe
parsePath :: Text -> PathResult
parsePath text =
- if | rest =~ ("^([^/]*[^\\./]/)*[^/]*[^\\./]$" :: Text) -> OkRelPath (Path up path fragment)
+ if | text =~ ("{{{.*}}}" :: Text) -> PathVarsDisallowed
+ | rest =~ ("^([^/]*[^\\./]/)*[^/]*[^\\./]$" :: Text) -> OkRelPath (Path up path fragment)
| "/_/" `isPrefixOf` text -> UnderscoreMapLink
| "/@/" `isPrefixOf` text -> AtMapLink
| "/" `isPrefixOf` text -> AbsolutePath