File tree 2 files changed +8
-10
lines changed
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):
915
915
916
916
917
917
def _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):
108
108
self .assertEqual ('https://host:8086' , cli ._baseurl )
109
109
110
110
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
+
111
114
cli = InfluxDBClient .from_DSN (self .dsn_string )
112
115
self .assertEqual ('http://my.host.fr:1886' , cli ._baseurl )
113
116
self .assertEqual ('uSr' , cli ._username )
You can’t perform that action at this time.
0 commit comments