[web-devel] A URL by another name...
michael at snoyman.com
Mon Sep 20 16:17:26 CEST 2010
Here's an opinion question for the web-devel list. In Yesod, I try to
ensure that we keep a single canonical URL for each resource, and
redirect non-canonical URL there. For example:
/foo/bar ---> /foo/bar/
/foo//bar/ ---> /foo/bar/
/static/myfile.png/ ---> /static/myfile.png
There are essentially two components to this cleanup: collapsing
multiple slashes and dealing with the trailing slash. If you pay
careful attention to the example above, you'll notice that there's a
subtlety to this trailing slash rule:
* If the last piece of the URL contains a period, it is assumed to be
a filename + extension, and therefore no trailing slash is used.
* Otherwise, a trailing slash is used.
My question is whether people would prefer a different default rule.
(I say default because you can easily override this setting using the
splitPath and joinPath functions.) The other two rules I could think
of are always requiring or always banning the trailing slash. I think
the former will make filenames look strange, but I don't really have a
strong feeling on the latter.
So the question is, what do y'all think?
More information about the web-devel