Trailing Slashes in URLs

0 views
Skip to first unread message

Joachim Breitner

unread,
Apr 2, 2008, 7:33:26 AM4/2/08
to HA...@googlegroups.com
Hi,

I’ve started another attempt to get familiar with HAppS and this time
it’s going quite well.

I have found a problem with trailing slashes though. To HAppS, a Request
for /a/b/c and /a/b/c/ is the same (both are turned into ["a","b","c"]
by splitList (in HApps.Utils) and put in the Request and the URI is then
forgotten). But to the browser, there is a difference when it comes to
relative links:

On /a/b/c:
"." -> /a/b/
"../" -> /a/
"d" -> /a/b/d
On /a/b/c/:
"." -> /a/b/c/
"../" -> /a/b/
"d" -> /a/b/c/d

One solution might be to add a rqURI field to the Request record that
contains the full unmodified URI of the request.


What I was trying to achieve is to use relative links in the HTML I
generate, because then I don’t need to re-construct the path. E.g. in
the POST handler for /object/123/modify/ I could use
> seeOther '../'
and would not have to remember the object id to reconstuct the path
to /object/123/.

I also only generate paths with a trailing slash, because it’s more
flexible. As you can see above, I can use relative links to append
something to a path without knowing anything of the path. This means I
can use the static link "modify/" on the page "/object/123" – another
piece of code made simple.

This works all well until the user enters an URL without the trailing
slash manually and all relative links go to wrong places. I tried to fix
this with a handler before other handlers that would redirect (seeOther)
the URI with a slash appended – that’s when I found out that this
information is lost.

Are there other solutions? How do you handle relative links? Would a
patch adding a rqURI field be accepted?

Thanks,
Joachim


--
Joachim "nomeata" Breitner
mail: ma...@joachim-breitner.de | ICQ# 74513189 | GPG-Key: 4743206C
JID: nom...@joachim-breitner.de | http://www.joachim-breitner.de/
Debian Developer: nom...@debian.org

signature.asc
Reply all
Reply to author
Forward
0 new messages