summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimonas Kazlauskas <git@kazlauskas.me>2013-04-01 15:10:46 +0300
committerSimonas Kazlauskas <git@kazlauskas.me>2013-04-01 15:10:46 +0300
commit128f10deb8e06a0137f06165aa3b6166564ac28d (patch)
treeaf097087ff8d04b0887d7912f66a85624378c181 /src
parentbf496c2f55f61f53fdc0ef7a03db7dc098ae766d (diff)
downloadhakyll-128f10deb8e06a0137f06165aa3b6166564ac28d.tar.gz
Properly implement protocol skipping in checker
Network.HTTP can only check if http:// and https:// links resolve, however there is much more scheme names than just `mail:`, `http://` and `https://`. They would be handed off to internal URI checker and would fail.
Diffstat (limited to 'src')
-rw-r--r--src/Hakyll/Check.hs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/Hakyll/Check.hs b/src/Hakyll/Check.hs
index 5c05aa5..10e7df0 100644
--- a/src/Hakyll/Check.hs
+++ b/src/Hakyll/Check.hs
@@ -137,15 +137,23 @@ checkFile filePath = do
--------------------------------------------------------------------------------
checkUrl :: FilePath -> String -> Checker ()
checkUrl filePath url
- | isExternal url = checkExternalUrl url
- | "mailto:" `isPrefixOf` url = ok url
- | otherwise = checkInternalUrl filePath url
-
+ | isExternal url = checkExternalUrl url
+ | hasProtocol url = skip "Unknown protocol, skipping"
+ | otherwise = checkInternalUrl filePath url
+ where
+ hasProtocol = all (`elem` validProtoChars) . takeWhile (/= ':')
+ validProtoChars = ['A'..'Z'] ++ ['a'..'z'] ++ ['0'..'9'] ++ "+-."
--------------------------------------------------------------------------------
ok :: String -> Checker ()
ok _ = tell $ mempty {checkerOk = 1}
+--------------------------------------------------------------------------------
+skip :: String -> Checker ()
+skip reason = do
+ logger <- checkerLogger <$> ask
+ Logger.debug logger $ reason
+ tell $ mempty {checkerOk = 1}
--------------------------------------------------------------------------------
faulty :: String -> Checker ()