From cf71e295467aa75606d491627541610e17dd1c64 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Tue, 8 Mar 2011 11:03:07 +0100 Subject: Make toSiteRoot work with /xxx URL's --- src/Hakyll/Web/RelativizeUrls.hs | 2 +- src/Hakyll/Web/Util/Url.hs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Hakyll/Web/RelativizeUrls.hs b/src/Hakyll/Web/RelativizeUrls.hs index 2de4a0e..06b4ae2 100644 --- a/src/Hakyll/Web/RelativizeUrls.hs +++ b/src/Hakyll/Web/RelativizeUrls.hs @@ -31,7 +31,7 @@ import Hakyll.Core.Compiler import Hakyll.Web.Page import Hakyll.Web.Util.Url --- | Compiler form of 'compressCss' which automatically picks the right root +-- | Compiler form of 'relativizeUrls' which automatically picks the right root -- path -- relativizeUrlsCompiler :: Compiler (Page String) (Page String) diff --git a/src/Hakyll/Web/Util/Url.hs b/src/Hakyll/Web/Util/Url.hs index 8a02ef3..a0702d8 100644 --- a/src/Hakyll/Web/Util/Url.hs +++ b/src/Hakyll/Web/Util/Url.hs @@ -24,8 +24,10 @@ toUrl url = '/' : url -- | Get the relative url to the site root, for a given (absolute) url -- toSiteRoot :: String -> String -toSiteRoot = emptyException . joinPath . map parent . splitPath . takeDirectory +toSiteRoot = emptyException . joinPath . map parent + . splitPath . takeDirectory . dropLeadingSlash where parent = const ".." emptyException [] = "." emptyException x = x + dropLeadingSlash = dropWhile (== '/') -- cgit v1.2.3