diff options
author | stuebinm | 2021-12-04 15:12:30 +0100 |
---|---|---|
committer | stuebinm | 2021-12-12 17:42:38 +0100 |
commit | 0dbe448959d6aa03f0ea99a7e180e2cafaedf651 (patch) | |
tree | 7a4a60f169a7e12c719e8c9555971ea645e6c41a /lib/Uris.hs | |
parent | 6a67d3e41fc49e09ed6c1c02fec2946c6db9bc1f (diff) |
better lints for invalid links
Diffstat (limited to '')
-rw-r--r-- | lib/Uris.hs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/Uris.hs b/lib/Uris.hs index dfbd454..b674d37 100644 --- a/lib/Uris.hs +++ b/lib/Uris.hs @@ -57,15 +57,19 @@ data SubstError = | NotALink | IsBlocked | InvalidLink - | WrongScope Text + | WrongScope Text [Text] + -- ^ 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. -applySubst :: KnownSymbol s => Proxy s -> SchemaSet -> Text -> Either SubstError Text +applySubst :: KnownSymbol s + => Proxy s -> SchemaSet -> Text -> Either SubstError Text applySubst s substs uri = do (schema, domain, rest) <- note NotALink $ parseUri uri rules <- note (SchemaDoesNotExist schema) ( M.lookup schema substs) unless (symbolVal s `elem` scope rules) - $ Left (WrongScope schema) + $ Left (WrongScope schema + (M.keys . M.filter (elem (symbolVal s) . scope) $ substs)) case rules of Explicit table _ -> do prefix <- note InvalidLink $ M.lookup domain table |