minor: support dash in host name on parse_uri
This commit is contained in:
parent
c28b126267
commit
51140f8ea1
|
@ -32,7 +32,7 @@ module Mongo
|
||||||
STANDARD_HEADER_SIZE = 16
|
STANDARD_HEADER_SIZE = 16
|
||||||
RESPONSE_HEADER_SIZE = 20
|
RESPONSE_HEADER_SIZE = 20
|
||||||
|
|
||||||
MONGODB_URI_MATCHER = /(([.\w\d]+):([\w\d]+)@)?([.\w\d]+)(:([\w\d]+))?(\/([-\d\w]+))?/
|
MONGODB_URI_MATCHER = /(([.\w\d]+):([\w\d]+)@)?([-.\w\d]+)(:([\w\d]+))?(\/([-\d\w]+))?/
|
||||||
MONGODB_URI_SPEC = "mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/database]"
|
MONGODB_URI_SPEC = "mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/database]"
|
||||||
|
|
||||||
attr_reader :logger, :size, :host, :port, :nodes, :auths, :sockets, :checked_out
|
attr_reader :logger, :size, :host, :port, :nodes, :auths, :sockets, :checked_out
|
||||||
|
|
|
@ -66,6 +66,12 @@ class ConnectionTest < Test::Unit::TestCase
|
||||||
assert_equal ['localhost', 27017], @conn.nodes[0]
|
assert_equal ['localhost', 27017], @conn.nodes[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "allow a complex host names" do
|
||||||
|
host_name = "foo.bar-12345.org"
|
||||||
|
@conn = Connection.from_uri("mongodb://#{host_name}", :connect => false)
|
||||||
|
assert_equal [host_name, 27017], @conn.nodes[0]
|
||||||
|
end
|
||||||
|
|
||||||
should "parse a uri specifying multiple nodes" do
|
should "parse a uri specifying multiple nodes" do
|
||||||
@conn = Connection.from_uri("mongodb://localhost:27017,mydb.com:27018", :connect => false)
|
@conn = Connection.from_uri("mongodb://localhost:27017,mydb.com:27018", :connect => false)
|
||||||
assert_equal ['localhost', 27017], @conn.nodes[0]
|
assert_equal ['localhost', 27017], @conn.nodes[0]
|
||||||
|
|
Loading…
Reference in New Issue