File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -915,13 +915,8 @@ def parse_dsn(dsn):
915915
916916
917917def _parse_netloc (netloc ):
918- import re
919- parsed = re .findall (r'(\w*):(\w*)@([a-zA-Z0-9_\.]*):(\d*)' , netloc )
920- if not parsed :
921- raise ValueError ('Invalid netloc "{}".' .format (netloc ))
922-
923- info = parsed [0 ]
924- return {'username' : info [0 ] or None ,
925- 'password' : info [1 ] or None ,
926- 'host' : info [2 ] or 'localhost' ,
927- 'port' : info [3 ] or 8086 }
918+ info = urlparse ("http://{}" .format (netloc ))
919+ return {'username' : info .username or None ,
920+ 'password' : info .password or None ,
921+ 'host' : info .hostname or 'localhost' ,
922+ 'port' : info .port or 8086 }
Original file line number Diff line number Diff line change @@ -108,6 +108,9 @@ def test_scheme(self):
108108 self .assertEqual ('https://host:8086' , cli ._baseurl )
109109
110110 def test_dsn (self ):
111+ cli = InfluxDBClient .from_DSN ('influxdb://192.168.0.1:1886' )
112+ self .assertEqual ('http://192.168.0.1:1886' , cli ._baseurl )
113+
111114 cli = InfluxDBClient .from_DSN (self .dsn_string )
112115 self .assertEqual ('http://my.host.fr:1886' , cli ._baseurl )
113116 self .assertEqual ('uSr' , cli ._username )
You can’t perform that action at this time.
0 commit comments