@@ -84,18 +84,15 @@ def __init__(self, value):
84
84
self .port = self .scheme == "https" and 443 or 80
85
85
self .public_key = parts .username
86
86
if not self .public_key :
87
- raise BadDsn ("Missing public key" )
87
+ raise BadDsn ("Missig public key" )
88
88
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" )
92
91
try :
93
- self .project_id = text_type (int (path . pop () ))
92
+ self .project_id = text_type (int (parts . path [ 1 :] ))
94
93
except (ValueError , TypeError ):
95
94
raise BadDsn ("Invalid project in DSN (%r)" % (parts .path or "" )[1 :])
96
95
97
- self .path = "/" .join (path ) + "/"
98
-
99
96
@property
100
97
def netloc (self ):
101
98
"""The netloc part of a DSN."""
@@ -109,20 +106,18 @@ def to_auth(self, client=None):
109
106
return Auth (
110
107
scheme = self .scheme ,
111
108
host = self .netloc ,
112
- path = self .path ,
113
109
project_id = self .project_id ,
114
110
public_key = self .public_key ,
115
111
secret_key = self .secret_key ,
116
112
client = client ,
117
113
)
118
114
119
115
def __str__ (self ):
120
- return "%s://%s%s@%s%s %s" % (
116
+ return "%s://%s%s@%s/ %s" % (
121
117
self .scheme ,
122
118
self .public_key ,
123
119
self .secret_key and "@" + self .secret_key or "" ,
124
120
self .netloc ,
125
- self .path ,
126
121
self .project_id ,
127
122
)
128
123
@@ -134,7 +129,6 @@ def __init__(
134
129
self ,
135
130
scheme ,
136
131
host ,
137
- path ,
138
132
project_id ,
139
133
public_key ,
140
134
secret_key = None ,
@@ -143,7 +137,6 @@ def __init__(
143
137
):
144
138
self .scheme = scheme
145
139
self .host = host
146
- self .path = path
147
140
self .project_id = project_id
148
141
self .public_key = public_key
149
142
self .secret_key = secret_key
@@ -153,12 +146,7 @@ def __init__(
153
146
@property
154
147
def store_api_url (self ):
155
148
"""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 )
162
150
163
151
def to_header (self , timestamp = None ):
164
152
"""Returns the auth header a string."""
0 commit comments