pombreda / gitit

Automatically exported from code.google.com/p/gitit
0 stars 0 forks source link

updir links on index page have // #88

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The page served at <http://gitit.johnmacfarlane.net/Cheese/> contains 
the segment:

<a class="updir" href="/_index"
>/</a 
><a class="updir" href="//Cheese/"
>Cheese/</a 
>

Firefox and Chrome interpret the // prefix as a sign of a link with a 
missing http: prefix and render this an an anchor linking to 
"http://Cheese/".

I *think* the problem is that a / is added to the path in Handlers.hs 
fileListToHtml:

      updirs = drop 1 $ inits $ splitPath $ '/' : prefix

and again in Framework.hs urlForPage:

    urlForPage page = "/" ++

I suspect the '/' added in fileListToHtml is a mistake, and will try to chase 
down consequences of removing it.

Original issue reported on code.google.com by brian.sn...@gmail.com on 9 Feb 2010 at 11:29

GoogleCodeExporter commented 9 years ago
An imperfect solution:

Author: Brian Sniffen <bts@v-rin.home>
Date:   Wed Feb 10 01:44:22 2010 -0500

    Modify urlForPage to never generate a leading //

diff --git a/Network/Gitit/Framework.hs b/Network/Gitit/Framework.hs
index 2fcfb2b..797e131 100644
--- a/Network/Gitit/Framework.hs
+++ b/Network/Gitit/Framework.hs
@@ -274,10 +274,12 @@ isSourceCode path' =
 -- | Returns encoded URL path for the page with the given name, relative to
 -- the wiki base.
 urlForPage :: String -> String
-urlForPage page = "/" ++
+urlForPage page = initialChar page ++
   encString True (\c -> isAscii c && (c `notElem` "?&")) (map spaceToPlus page)
     where spaceToPlus ' ' = '+'
           spaceToPlus c   = c
+          initialChar ('/':_) = ""
+          initialChar _       = "/"
 -- / and @ are left unescaped so that browsers recognize relative URLs and talk

 -- | Returns the filestore path of the file containing the page's source.

Original comment by brian.sn...@gmail.com on 10 Feb 2010 at 6:55

GoogleCodeExporter commented 9 years ago
Fixed in HEAD c4b694f

Original comment by fiddloso...@gmail.com on 14 Feb 2010 at 5:59

GoogleCodeExporter commented 9 years ago

Original comment by fiddloso...@gmail.com on 14 Feb 2010 at 5:59