parse_url removed more than one leading slash. Closes #121

This commit is contained in:
Ask Solem 2012-04-13 15:37:53 +01:00
parent 83759b3e4b
commit 0c7d822af0
2 changed files with 3 additions and 2 deletions

View File

@ -320,7 +320,7 @@ class Channel(virtual.Channel):
raise ValueError(
"Database name must be int between 0 and limit - 1")
return self.Client(host=conninfo.hostname,
return self.Client(host=conninfo.hostname or "127.0.0.1",
port=conninfo.port or DEFAULT_PORT,
db=database,
password=conninfo.password)

View File

@ -20,7 +20,8 @@ def _parse_url(url):
# This enables the use of replica sets and sharding.
# See pymongo.Connection() for more info.
hostname = schemeless if scheme == 'mongodb' else parts.hostname
path = (parts.path or '').lstrip('/')
path = parts.path or ''
path = path[1:] if path and path[0] == '/' else path
return (scheme, unquote(hostname or '') or None,
int(parts.port) if parts.port else None,
unquote(parts.username or '') or None,