diff --git a/src/Vervis/Readme.hs b/src/Vervis/Readme.hs index 22e61d4..00402a7 100644 --- a/src/Vervis/Readme.hs +++ b/src/Vervis/Readme.hs @@ -35,6 +35,13 @@ import System.FilePath (isExtSeparator) import Vervis.Foundation (Widget) import Vervis.Render (renderSource) +-- | Check if the given filename should be considered as README file. Assumes +-- a flat filename which doesn't contain a directory part. +isReadme :: Text -> Bool +isReadme file = + let basename = takeWhile (not . isExtSeparator) file + in toCaseFold "readme" == toCaseFold basename + -- | Find a README file in a directory. Return the filename and the file -- content. findReadme :: Git -> Tree -> IO (Maybe (Text, ByteString)) @@ -43,8 +50,7 @@ findReadme git tree = go $ treeGetEnts tree go [] = return Nothing go ((_perm, name, ref) : es) = let nameT = decodeUtf8With strictDecode $ toBytes name - base = takeWhile (not . isExtSeparator) nameT - in if toCaseFold "readme" == toCaseFold base + in if isReadme nameT then do obj <- getObject_ git ref True case obj of