couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Anderson" <jch...@apache.org>
Subject Re: slash escaping (was 0.9.0 Release)
Date Thu, 11 Dec 2008 21:44:36 GMT
On Thu, Dec 11, 2008 at 1:04 PM, Noah Slater <nslater@apache.org> wrote:
> People like using slashes in URLs, we can't change that.

Not only that, but developers often need control over the slashes of a
url (in order to make relative urls work nicely, etc). As it stands,
because some browsers treat urls like

http://jchris.mfdz.com:5984/couchblog/_design%2Fcouchdb-example-blog/index.html

as though it were

http://jchris.mfdz.com:5984/couchblog/_design/couchdb-example-blog/index.html

no matter what you do, there's no reliable way to link to say
../../docid from an attachment, without a dynamic attachment
(Javascript + browser) or hardcoding the database name in the
attachment. In the long run, pragmatism wins over perfection every
time.

Also, I've already experienced fail when trying to host static-HTML
websites in CouchDB. Because designers tend to stick things in
directories, I have to go through and change all the HTML to work with
a flat namespace. (Or not use CouchDB.)

I still stand my (modulo Damien's caveat) proposed slash-escaping rule
set. It differs from the empty rule set (aka urlencode everything) but
I think it does not lead to ambiguities. I'll restate it here with
more clarity:

Rules for Docs with IDs that start with '_' (currently only _design/
and _local/, as per spec)

/db/_design/name
/db/_design/name/attachment.file
/db/_design/name/attachment/with/slashes.file

There is an additional constraint on design docs (which is a bug if
it's not already enforced programmatically) that the name must be
filesystem safe. We already have code devoted to validating database
names, applying it here is a no-brainer. For _local docs or new system
types which don't have to go to the filesystem, URL-escaping the name
section is appropriate.

Rules for attachments on regular docs are the same as above:

/db/docid
/db/docid/attachment.file
/db/docid/attachment/with/slashes.file

Docids will be URL-encoded, as they are now. The only change is that
attachment paths will have real slashes.

-- 
Chris Anderson
http://jchris.mfdz.com

Mime
View raw message