diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2013-04-01 08:28:33 -0700 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2013-04-01 08:28:33 -0700 |
commit | 571ab4b8f77997340a3d18fca3eaf7d4b79da83b (patch) | |
tree | af097087ff8d04b0887d7912f66a85624378c181 | |
parent | bf496c2f55f61f53fdc0ef7a03db7dc098ae766d (diff) | |
parent | 128f10deb8e06a0137f06165aa3b6166564ac28d (diff) | |
download | hakyll-571ab4b8f77997340a3d18fca3eaf7d4b79da83b.tar.gz |
Merge pull request #129 from simukis/check-whitelist
Properly implement protocol skipping in checker
-rw-r--r-- | src/Hakyll/Check.hs | 16 |
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 () |