summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Cochrane <adrian@openwork.nz>2020-12-07 20:40:39 +1300
committerAdrian Cochrane <adrian@openwork.nz>2020-12-07 20:40:39 +1300
commit9794e7d56e818c566264c7c9a806912e7943767e (patch)
tree94af7a241d96a0025a5ec105f263de707068cd3a
parent70b80f77ae0e662b690f2829073e086eed7c7b8a (diff)
downloadhurl-9794e7d56e818c566264c7c9a806912e7943767e.tar.gz
hurl-9794e7d56e818c566264c7c9a806912e7943767e.tar.bz2
hurl-9794e7d56e818c566264c7c9a806912e7943767e.zip
Ensure parsed rewriters are actually files.
-rw-r--r--src/Network/URI/PlugIns/Rewriters.hs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/Network/URI/PlugIns/Rewriters.hs b/src/Network/URI/PlugIns/Rewriters.hs
index 8e5b46f..d033bc7 100644
--- a/src/Network/URI/PlugIns/Rewriters.hs
+++ b/src/Network/URI/PlugIns/Rewriters.hs
@@ -38,10 +38,13 @@ parseRewriters app = do
loadRewriters dir = do
files <- Dir.listDirectory dir
raw <- forConcurrently files $ \file -> do
- rewriter <- parseRewriter file
- return $ case rewriter of
- Select x -> x
- Pipe x -> x
+ exists <- doesFileExist file
+ if exists then do
+ rewriter <- parseRewriter file
+ return $ case rewriter of
+ Select x -> x
+ Pipe x -> x
+ else return []
return $ concat raw
applyRewriter :: Rewriter -> URI -> Maybe URI