couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Shorin (JIRA)" <>
Subject [jira] [Updated] (COUCHDB-1006) Ability to replace substrings in rewriter
Date Fri, 28 Jun 2013 01:48:21 GMT


Alexander Shorin updated COUCHDB-1006:

    Component/s:     (was: Database Core)
                 HTTP Interface
> Ability to replace substrings in rewriter
> -----------------------------------------
>                 Key: COUCHDB-1006
>                 URL:
>             Project: CouchDB
>          Issue Type: Improvement
>          Components: HTTP Interface
>            Reporter: Volker Mische
>            Priority: Minor
>         Attachments: rewrite-replace.patch
> The current rewriter is bound to the parts of a path. Therefore I propose and additional
"replace" property to be able to rewrite URLs beyond that limitation. One example would be
subpages in a wiki, where each subpage corresponds to one document in the database. Here's
an example:
> Desired URL:
> URL without rewriting:
> Another use case is when you have to deal with attachments. For example if you want to
build a TMS tilecache [1] bases on CouchDB. My URL would look like this (where "tile" is the
> But I'd need an URL like
> (resp.
> My modification to the rewriter allows you to replace substrings with other ones. Here's
the rewriter rule for this example:
> {
>     "from" : "/tiles/<x>/<y>/<z>.png",
>     "to" : "..\\/..\\/:x/:y/:z/tile",
>     "replace": {
>         "old": "/",
>         "new": "-",
>         "limit": -1
>     }
> }
> It replaces all occurences of "/" with "-" on the "to"-path. Two slashes ("\\") escape
a character, so it won't be replaced. The "limit" parameter specifies how many occurences
should be replaced. It could be either positive, then it will just count how often a string
was already replaced and stop at the limit. If "limit" is negative, it will count from the
back. This is especially useful if you want to replace slashes and know how many slashes the
attachment has, but not how many the document has.
> [1] 

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message