diff options
Diffstat (limited to 'src/fabric.erl')
-rw-r--r-- | src/fabric.erl | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/fabric.erl b/src/fabric.erl index e75e31eb..0957387e 100644 --- a/src/fabric.erl +++ b/src/fabric.erl @@ -1,10 +1,18 @@ -module(fabric). -export([all_databases/1, create_db/2, delete_db/2, open_doc/3, open_doc/4, - get_db_info/2]). + get_db_info/2, db_path/2]). + +-include("../../couch/src/couch_db.hrl"). % db operations +-spec db_path(bstring(), bstring()) -> bstring(). +db_path(RawUri, Customer) -> + CustomerUri = generate_customer_path(RawUri, Customer), + {Path, _, _} = mochiweb_util:urlsplit_path(CustomerUri), + Path. + all_databases(Customer) -> fabric_db:all_databases(Customer). @@ -22,4 +30,23 @@ open_doc(Db, DocId, Options) -> fabric_doc:open_doc(Db, DocId, Options). open_doc(Db, DocId, Revs, Options) -> - fabric_open:open_doc(Db, DocId, Revs, Options). + fabric_doc:open_doc(Db, DocId, Revs, Options). + + + +%% +%% internal +%% +generate_customer_path("/", _Customer) -> + ""; +generate_customer_path("/favicon.ico", _Customer) -> + "favicon.ico"; +generate_customer_path([$/,$_|Rest], _Customer) -> + lists:flatten([$_|Rest]); +generate_customer_path([$/|RawPath], Customer) -> + case Customer of + "" -> + RawPath; + Else -> + lists:flatten([Else, "%2F", RawPath]) + end. |