summaryrefslogtreecommitdiff
path: root/src/Hakyll
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2013-06-15 20:15:33 +0200
committerJasper Van der Jeugt <m@jaspervdj.be>2013-06-15 20:15:33 +0200
commit537e72333f8deafa59219b60dcae0a4f52569317 (patch)
treeadfc1212c510ff8196ef1ac99139083978a88db2 /src/Hakyll
parenta591b1622fe9608bc1dc485b74a54730c958bf4d (diff)
downloadhakyll-537e72333f8deafa59219b60dcae0a4f52569317.tar.gz
Sanitize URLs in toUrl
Closes #163
Diffstat (limited to 'src/Hakyll')
-rw-r--r--src/Hakyll/Web/Html.hs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Hakyll/Web/Html.hs b/src/Hakyll/Web/Html.hs
index 58b5c43..d06b7c2 100644
--- a/src/Hakyll/Web/Html.hs
+++ b/src/Hakyll/Web/Html.hs
@@ -98,9 +98,17 @@ renderTags' = TS.renderTagsOptions TS.renderOptions
-- Result:
--
-- > "/foo/bar.html"
+--
+-- This also sanitizes the URL, e.g. converting spaces into '%20'
toUrl :: FilePath -> String
-toUrl ('/' : xs) = '/' : xs
-toUrl url = '/' : url
+toUrl url = case url of
+ ('/' : xs) -> '/' : sanitize xs
+ xs -> '/' : sanitize xs
+ where
+ -- This probably needs to be a separate function
+ sanitize = concatMap $ \c -> case c of
+ ' ' -> "%20"
+ _ -> [c]
--------------------------------------------------------------------------------