@@ -84,18 +84,15 @@ def __init__(self, value):
8484 self .port = self .scheme == "https" and 443 or 80
8585 self .public_key = parts .username
8686 if not self .public_key :
87- raise BadDsn ("Missing public key" )
87+ raise BadDsn ("Missig public key" )
8888 self .secret_key = parts .password
89-
90- path = parts .path .rsplit ("/" , 1 )
91-
89+ if not parts .path :
90+ raise BadDsn ("Missing project ID in DSN" )
9291 try :
93- self .project_id = text_type (int (path . pop () ))
92+ self .project_id = text_type (int (parts . path [ 1 :] ))
9493 except (ValueError , TypeError ):
9594 raise BadDsn ("Invalid project in DSN (%r)" % (parts .path or "" )[1 :])
9695
97- self .path = "/" .join (path ) + "/"
98-
9996 @property
10097 def netloc (self ):
10198 """The netloc part of a DSN."""
@@ -109,20 +106,18 @@ def to_auth(self, client=None):
109106 return Auth (
110107 scheme = self .scheme ,
111108 host = self .netloc ,
112- path = self .path ,
113109 project_id = self .project_id ,
114110 public_key = self .public_key ,
115111 secret_key = self .secret_key ,
116112 client = client ,
117113 )
118114
119115 def __str__ (self ):
120- return "%s://%s%s@%s%s %s" % (
116+ return "%s://%s%s@%s/ %s" % (
121117 self .scheme ,
122118 self .public_key ,
123119 self .secret_key and "@" + self .secret_key or "" ,
124120 self .netloc ,
125- self .path ,
126121 self .project_id ,
127122 )
128123
@@ -134,7 +129,6 @@ def __init__(
134129 self ,
135130 scheme ,
136131 host ,
137- path ,
138132 project_id ,
139133 public_key ,
140134 secret_key = None ,
@@ -143,7 +137,6 @@ def __init__(
143137 ):
144138 self .scheme = scheme
145139 self .host = host
146- self .path = path
147140 self .project_id = project_id
148141 self .public_key = public_key
149142 self .secret_key = secret_key
@@ -153,12 +146,7 @@ def __init__(
153146 @property
154147 def store_api_url (self ):
155148 """Returns the API url for storing events."""
156- return "%s://%s%sapi/%s/store/" % (
157- self .scheme ,
158- self .host ,
159- self .path ,
160- self .project_id ,
161- )
149+ return "%s://%s/api/%s/store/" % (self .scheme , self .host , self .project_id )
162150
163151 def to_header (self , timestamp = None ):
164152 """Returns the auth header a string."""
0 commit comments