Skip to content
Snippets Groups Projects
Commit 65e496a8 authored by stuebinm's avatar stuebinm
Browse files

generalise unwrapURI a bit

parent 5c69c311
Branches
No related tags found
No related merge requests found
Pipeline #10300 passed
...@@ -566,13 +566,17 @@ unwrapBadgeToken str f = case parseToken str of ...@@ -566,13 +566,17 @@ unwrapBadgeToken str f = case parseToken str of
Nothing -> complain "invalid badge token." Nothing -> complain "invalid badge token."
unwrapURI :: (KnownSymbol s, HasProperties a) -- | unwraps a URI
=> Proxy s -> Property -> (Text -> LintWriter a) -> (RelPath -> LintWriter a) -> LintWriter a unwrapURI' :: (KnownSymbol s)
unwrapURI sym p@(Property name _) f g = unwrapString p $ \link -> do => Proxy s
-> Property
-> (Text -> LintWriter a)
-> (RelPath -> LintWriter a)
-> LintWriter a
unwrapURI' sym p@(Property name _) f g = unwrapString p $ \link -> do
subst <- lintConfig configUriSchemas subst <- lintConfig configUriSchemas
case applySubst sym subst link of case applySubst sym subst link of
Right uri -> do Right uri -> do
setProperty name uri
f uri f uri
Left NotALink -> unwrapPath link g Left NotALink -> unwrapPath link g
Left err -> complain $ case err of Left err -> complain $ case err of
...@@ -588,6 +592,17 @@ unwrapURI sym p@(Property name _) f g = unwrapString p $ \link -> do ...@@ -588,6 +592,17 @@ unwrapURI sym p@(Property name _) f g = unwrapString p $ \link -> do
<> intercalate ", " (fmap (<> "://") allowed) <> "." <> intercalate ", " (fmap (<> "://") allowed) <> "."
VarsDisallowed -> "extended API links are disallowed in links" VarsDisallowed -> "extended API links are disallowed in links"
-- | unwraps a URI and adjusts the linter's output
unwrapURI :: (KnownSymbol s, HasProperties a)
=> Proxy s
-> Property
-> (Text -> LintWriter a)
-> (RelPath -> LintWriter a)
-> LintWriter a
unwrapURI sym p@(Property name _) f =
unwrapURI' sym p $ \uri -> setProperty name uri >> f uri
-- | just asserts that this is a string -- | just asserts that this is a string
isString :: Property -> LintWriter a isString :: Property -> LintWriter a
isString = flip unwrapString (const $ pure ()) isString = flip unwrapString (const $ pure ())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment