summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2009-12-28 13:46:43 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2009-12-28 13:46:43 +0100
commit4561887cf459ca9c06067180a979e996b029dcdf (patch)
tree87952368fc30d4f9e8bcec9a53037d7abef7d7dc /src
parentf4f1d86ca8ff19192ce742c555a6e8236bacdd78 (diff)
downloadhakyll-4561887cf459ca9c06067180a979e996b029dcdf.tar.gz
Find index.html in every directory.
Diffstat (limited to 'src')
-rw-r--r--src/Network/Hakyll/SimpleServer.hs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/Network/Hakyll/SimpleServer.hs b/src/Network/Hakyll/SimpleServer.hs
index 80c0ff1..1a4b1c6 100644
--- a/src/Network/Hakyll/SimpleServer.hs
+++ b/src/Network/Hakyll/SimpleServer.hs
@@ -8,7 +8,7 @@ import Network
import Control.Monad (forever, mapM_)
import Control.Monad.Reader (ReaderT, runReaderT, ask, liftIO)
import System.IO (Handle, hClose, hGetLine, hPutStr)
-import System.Directory (doesFileExist)
+import System.Directory (doesFileExist, doesDirectoryExist)
import Control.Concurrent (forkIO)
import System.FilePath (takeExtension)
import qualified Data.ByteString.Char8 as B
@@ -92,8 +92,9 @@ createGetResponse request = do
-- Construct the complete fileName of the requested resource.
config <- ask
let uri = B.unpack (requestURI request)
- fileName = (documentRoot config) ++ if uri == "/" then "/index.html"
- else B.unpack (requestURI request)
+ isDirectory <- liftIO $ doesDirectoryExist $ documentRoot config ++ uri
+ let fileName = (documentRoot config) ++ if isDirectory then uri ++ "/index.html"
+ else uri
-- Send back the page if found.
exists <- liftIO $ doesFileExist fileName