From 35354a18a7e541ed93c1bf4c7d722e7b1fdeae46 Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Thu, 14 Apr 2016 00:01:56 +0000 Subject: [PATCH] Detect README based on file basename --- src/Vervis/Readme.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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