diff options
author | Sven G. Brönstrup | 2021-12-20 00:32:44 +0100 |
---|---|---|
committer | Sven G. Brönstrup | 2021-12-20 00:32:44 +0100 |
commit | 7e65bc46f66c6073c998cfaea2a9644cbb9b896a (patch) | |
tree | a0d932cc4c26b3c3e63b61c7e39df4b3c816fb94 /lib/Uris.hs | |
parent | 8f5af0492e7a82192d1fafda3d2c74421af4354d (diff) | |
parent | 5060f68b9728bf94818ee985c16c25511f248143 (diff) |
Merge branch 'main' into extended-scripts
Diffstat (limited to '')
-rw-r--r-- | lib/Uris.hs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Uris.hs b/lib/Uris.hs index 5ad9180..e2d9a5f 100644 --- a/lib/Uris.hs +++ b/lib/Uris.hs @@ -9,7 +9,7 @@ module Uris where -import Control.Monad (unless) +import Control.Monad (unless, when) import Data.Aeson (FromJSON (..), Options (..), SumEncoding (UntaggedValue), defaultOptions, genericParseJSON) @@ -58,6 +58,7 @@ data SubstError = | IsBlocked | DomainDoesNotExist Text | WrongScope Text [Text] + | VarsDisallowed -- ^ This link's schema exists, but cannot be used in this scope. -- The second field contains a list of schemas that may be used instead. @@ -65,7 +66,10 @@ data SubstError = applySubst :: KnownSymbol s => Proxy s -> SchemaSet -> Text -> Either SubstError Text applySubst s substs uri = do + when (uri =~ "{{{.*}}}") + $ Left VarsDisallowed (schema, domain, rest) <- note NotALink $ parseUri uri + rules <- note (SchemaDoesNotExist schema) ( M.lookup schema substs) unless (symbolVal s `elem` scope rules) $ Left (WrongScope schema |