diff -Bubr CouchDB-Client-0.08.orig/lib/CouchDB/Client/DB.pm CouchDB-Client-0.08/lib/CouchDB/Client/DB.pm
--- CouchDB-Client-0.08.orig/lib/CouchDB/Client/DB.pm 2010-05-17 01:29:34.000000000 +0900
+++ CouchDB-Client-0.08/lib/CouchDB/Client/DB.pm 2010-08-05 03:33:04.000000000 +0900
@@ -17,7 +17,6 @@
$opt{name} || confess "CouchDB database requires a name.";
$opt{client} || confess "CouchDB database requires a client.";
- $opt{name} .= '/' unless $opt{name} =~ m{/$};
return bless \%opt, $class;
}
@@ -30,8 +29,7 @@
sub uriName {
my $self = shift;
- my $sn = $self->{name};
- $sn =~ s{/(.)}{%2F$1}g;
+ my $sn = uri_escape_utf8($self->{name});
return "$sn";
}
@@ -112,7 +110,7 @@
my $self = shift;
my %args = @_;
my $qs = %args ? $self->argsToQuery(%args) : '';
- my $res = $self->{client}->req('GET', $self->uriName . '_all_docs' . $qs);
+ my $res = $self->{client}->req('GET', $self->uriName . '/_all_docs' . $qs);
confess("Connection error: $res->{msg}") unless $res->{success};
return [
map {
@@ -179,7 +177,7 @@
sub tempView {
my $self = shift;
my $view = shift;
- my $res = $self->{client}->req('POST', $self->uriName . '_temp_view', $view);
+ my $res = $self->{client}->req('POST', $self->uriName . '/_temp_view', $view);
return $res->{json} if $res->{success};
confess("Connection error: $res->{msg}");
}
@@ -188,7 +186,7 @@
my $self = shift;
my $docs = shift;
my $json = { docs => [map { $_->contentForSubmit } @$docs] };
- my $res = $self->{client}->req('POST', $self->uriName . '_bulk_docs', $json);
+ my $res = $self->{client}->req('POST', $self->uriName . '/_bulk_docs', $json);
confess("Connection error: $res->{msg}") unless $res->{success};
my $i = 0;
@@ -208,7 +206,7 @@
my $self = shift;
my $docs = shift;
my $json = { docs => [map { my $cnt = $_->contentForSubmit; $cnt->{_deleted} = $self->{client}->{json}->true; $cnt; } @$docs] };
- my $res = $self->{client}->req('POST', $self->uriName . '_bulk_docs', $json);
+ my $res = $self->{client}->req('POST', $self->uriName . '/_bulk_docs', $json);
confess("Connection error: $res->{msg}") unless $res->{success};
my $i = 0;
diff -Bubr CouchDB-Client-0.08.orig/lib/CouchDB/Client/DesignDoc.pm CouchDB-Client-0.08/lib/CouchDB/Client/DesignDoc.pm
--- CouchDB-Client-0.08.orig/lib/CouchDB/Client/DesignDoc.pm 2010-03-22 09:48:57.000000000 +0900
+++ CouchDB-Client-0.08/lib/CouchDB/Client/DesignDoc.pm 2010-08-05 03:23:42.000000000 +0900
@@ -6,6 +6,7 @@
our $VERSION = $CouchDB::Client::VERSION;
use base qw(CouchDB::Client::Doc);
+use URI::Escape qw(uri_escape_utf8);
use Carp qw(confess);
@@ -42,6 +43,7 @@
confess("No such view: '$view'") unless exists $self->views->{$view};
my $sn = $self->id;
$sn =~ s{^_design/}{};
+ $sn = uri_escape_utf8($sn);
# The uri path for views changed and the parameter "count" has been renamed "limit"
# between v0.8 and v0.9 and above. (issue #48407 and #49759 in RT)
@@ -49,14 +51,14 @@
my $vp;
if ($M > 0 || ($M == 0 && $m >= 9)) {
- $vp = "_design/$sn/_view/$view";
+ $vp = "/_design/$sn/_view/$view";
if (defined($args{count})) {
$args{limit} = $args{count};
delete $args{count};
}
}
else {
- $vp = "_view/$sn/$view";
+ $vp = "/_view/$sn/$view";
if (defined($args{limit})) {
$args{count} = $args{limit};
delete $args{limit};
diff -Bubr CouchDB-Client-0.08.orig/lib/CouchDB/Client/Doc.pm CouchDB-Client-0.08/lib/CouchDB/Client/Doc.pm
--- CouchDB-Client-0.08.orig/lib/CouchDB/Client/Doc.pm 2010-03-22 09:48:47.000000000 +0900
+++ CouchDB-Client-0.08/lib/CouchDB/Client/Doc.pm 2010-08-05 03:08:23.000000000 +0900
@@ -46,7 +46,7 @@
sub uriName {
my $self = shift;
return undef unless $self->{id};
- return $self->{db}->uriName . $self->{id};
+ return $self->{db}->uriName . '/' . uri_escape_utf8($self->{id});
}
sub create {
diff -Bubr CouchDB-Client-0.08.orig/t/15-client.t CouchDB-Client-0.08/t/15-client.t
--- CouchDB-Client-0.08.orig/t/15-client.t 2010-03-22 09:57:13.000000000 +0900
+++ CouchDB-Client-0.08/t/15-client.t 2010-08-05 03:17:52.000000000 +0900
@@ -9,10 +9,10 @@
my $cdb = CouchDB::Client->new( uri => $ENV{COUCHDB_CLIENT_URI} || '
http://localhost:5984/' );
# CONFIG
-my $dbName = 'test-perl-couchdb-client/';
-my $dbNameNot = 'test-perl-couchdb-client-NOT-EXISTS/';
+my $dbName = 'test-perl/couchdb-client';
+my $dbNameNot = 'test-perl/couchdb-client/NOT-EXISTS';
my $dbNameReplicated = 'test-perl-couchdb-client-replicated';
-my $baseDocName = 'TEST-DOC';
+my $baseDocName = 'TEST/DOC';
if($cdb->testConnection) {
my $v = $cdb->serverInfo->{version};
@@ -122,7 +122,7 @@
{
my $info = $DB->dbInfo;
ok $info, "dbInfo available";
- ok $info->{db_name} . '/' eq $dbName, "Data in dbInfo";
+ ok $info->{db_name} eq $dbName, "Data in dbInfo";
}
# new Doc, list and exists