diff --git a/src/Vervis/Readme.hs b/src/Vervis/Readme.hs index 884dc73..22e61d4 100644 --- a/src/Vervis/Readme.hs +++ b/src/Vervis/Readme.hs @@ -20,16 +20,17 @@ module Vervis.Readme ) where -import Prelude +import Prelude hiding (takeWhile) import Data.Byteable (toBytes) import Data.ByteString.Lazy (ByteString) import Data.Git.Storage (Git, getObject_) import Data.Git.Storage.Object (Object (..)) import Data.Git.Types (Blob (..), Tree (..)) -import Data.Text (Text, toCaseFold, isPrefixOf, unpack) +import Data.Text (Text, toCaseFold, takeWhile, unpack) import Data.Text.Encoding (decodeUtf8With) import Data.Text.Encoding.Error (strictDecode) +import System.FilePath (isExtSeparator) import Vervis.Foundation (Widget) import Vervis.Render (renderSource) @@ -42,7 +43,8 @@ findReadme git tree = go $ treeGetEnts tree go [] = return Nothing go ((_perm, name, ref) : es) = let nameT = decodeUtf8With strictDecode $ toBytes name - in if toCaseFold "readme" `isPrefixOf` toCaseFold nameT + base = takeWhile (not . isExtSeparator) nameT + in if toCaseFold "readme" == toCaseFold base then do obj <- getObject_ git ref True case obj of