Added support for https database URIs.
Signed-off-by: Tapajós <tapajos@gmail.com>
This commit is contained in:
parent
2f2c507582
commit
d8e7652680
|
@ -96,14 +96,14 @@ module CouchRest
|
|||
|
||||
def parse url
|
||||
case url
|
||||
when /^http:\/\/(.*)\/(.*)\/(.*)/
|
||||
when /^https?:\/\/(.*)\/(.*)\/(.*)/
|
||||
host = $1
|
||||
db = $2
|
||||
docid = $3
|
||||
when /^http:\/\/(.*)\/(.*)/
|
||||
when /^https?:\/\/(.*)\/(.*)/
|
||||
host = $1
|
||||
db = $2
|
||||
when /^http:\/\/(.*)/
|
||||
when /^https?:\/\/(.*)/
|
||||
host = $1
|
||||
when /(.*)\/(.*)\/(.*)/
|
||||
host = $1
|
||||
|
|
|
@ -54,7 +54,7 @@ describe CouchRest do
|
|||
db[:host].should == "127.0.0.1"
|
||||
end
|
||||
it "should parse a host and db with http" do
|
||||
db = CouchRest.parse "http://127.0.0.1/my-db"
|
||||
db = CouchRest.parse "https://127.0.0.1/my-db"
|
||||
db[:database].should == "my-db"
|
||||
db[:host].should == "127.0.0.1"
|
||||
end
|
||||
|
@ -68,16 +68,31 @@ describe CouchRest do
|
|||
db[:database].should == "my-db"
|
||||
db[:host].should == "127.0.0.1:5555"
|
||||
end
|
||||
it "should parse a host with a port and db with https" do
|
||||
db = CouchRest.parse "https://127.0.0.1:5555/my-db"
|
||||
db[:database].should == "my-db"
|
||||
db[:host].should == "127.0.0.1:5555"
|
||||
end
|
||||
it "should parse just a host" do
|
||||
db = CouchRest.parse "http://127.0.0.1:5555/"
|
||||
db[:database].should be_nil
|
||||
db[:host].should == "127.0.0.1:5555"
|
||||
end
|
||||
it "should parse just a host with https" do
|
||||
db = CouchRest.parse "https://127.0.0.1:5555/"
|
||||
db[:database].should be_nil
|
||||
db[:host].should == "127.0.0.1:5555"
|
||||
end
|
||||
it "should parse just a host no slash" do
|
||||
db = CouchRest.parse "http://127.0.0.1:5555"
|
||||
db[:host].should == "127.0.0.1:5555"
|
||||
db[:database].should be_nil
|
||||
end
|
||||
it "should parse just a host no slash and https" do
|
||||
db = CouchRest.parse "https://127.0.0.1:5555"
|
||||
db[:host].should == "127.0.0.1:5555"
|
||||
db[:database].should be_nil
|
||||
end
|
||||
it "should get docid" do
|
||||
db = CouchRest.parse "127.0.0.1:5555/my-db/my-doc"
|
||||
db[:database].should == "my-db"
|
||||
|
@ -90,7 +105,12 @@ describe CouchRest do
|
|||
db[:host].should == "127.0.0.1:5555"
|
||||
db[:doc].should == "my-doc"
|
||||
end
|
||||
|
||||
it "should get docid with https" do
|
||||
db = CouchRest.parse "https://127.0.0.1:5555/my-db/my-doc"
|
||||
db[:database].should == "my-db"
|
||||
db[:host].should == "127.0.0.1:5555"
|
||||
db[:doc].should == "my-doc"
|
||||
end
|
||||
it "should parse a host and db" do
|
||||
db = CouchRest.parse "127.0.0.1/my-db"
|
||||
db[:database].should == "my-db"
|
||||
|
@ -101,6 +121,11 @@ describe CouchRest do
|
|||
db[:database].should == "my-db"
|
||||
db[:host].should == "127.0.0.1"
|
||||
end
|
||||
it "should parse a host and db with https" do
|
||||
db = CouchRest.parse "https://127.0.0.1/my-db"
|
||||
db[:database].should == "my-db"
|
||||
db[:host].should == "127.0.0.1"
|
||||
end
|
||||
it "should parse a host with a port and db" do
|
||||
db = CouchRest.parse "127.0.0.1:5555/my-db"
|
||||
db[:database].should == "my-db"
|
||||
|
@ -111,16 +136,31 @@ describe CouchRest do
|
|||
db[:database].should == "my-db"
|
||||
db[:host].should == "127.0.0.1:5555"
|
||||
end
|
||||
it "should parse a host with a port and db with https" do
|
||||
db = CouchRest.parse "http://127.0.0.1:5555/my-db"
|
||||
db[:database].should == "my-db"
|
||||
db[:host].should == "127.0.0.1:5555"
|
||||
end
|
||||
it "should parse just a host" do
|
||||
db = CouchRest.parse "http://127.0.0.1:5555/"
|
||||
db[:database].should be_nil
|
||||
db[:host].should == "127.0.0.1:5555"
|
||||
end
|
||||
it "should parse just a host with https" do
|
||||
db = CouchRest.parse "https://127.0.0.1:5555/"
|
||||
db[:database].should be_nil
|
||||
db[:host].should == "127.0.0.1:5555"
|
||||
end
|
||||
it "should parse just a host no slash" do
|
||||
db = CouchRest.parse "http://127.0.0.1:5555"
|
||||
db[:host].should == "127.0.0.1:5555"
|
||||
db[:database].should be_nil
|
||||
end
|
||||
it "should parse just a host no slash and https" do
|
||||
db = CouchRest.parse "https://127.0.0.1:5555"
|
||||
db[:host].should == "127.0.0.1:5555"
|
||||
db[:database].should be_nil
|
||||
end
|
||||
it "should get docid" do
|
||||
db = CouchRest.parse "127.0.0.1:5555/my-db/my-doc"
|
||||
db[:database].should == "my-db"
|
||||
|
@ -133,6 +173,12 @@ describe CouchRest do
|
|||
db[:host].should == "127.0.0.1:5555"
|
||||
db[:doc].should == "my-doc"
|
||||
end
|
||||
it "should get docid with https" do
|
||||
db = CouchRest.parse "https://127.0.0.1:5555/my-db/my-doc"
|
||||
db[:database].should == "my-db"
|
||||
db[:host].should == "127.0.0.1:5555"
|
||||
db[:doc].should == "my-doc"
|
||||
end
|
||||
end
|
||||
|
||||
describe "easy initializing a database adapter" do
|
||||
|
|
Loading…
Reference in a new issue