Skip to content

Commit d5e6077

Browse files
Improved URL construction
1 parent 7b9b5a3 commit d5e6077

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

inventree/api.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,8 @@ def constructApiUrl(self, endpoint_url):
145145
Returns: A fully qualified URL for the subsequent request
146146
"""
147147

148-
# Strip leading / character if provided
149-
if endpoint_url.startswith("/"):
150-
endpoint_url = endpoint_url[1:]
148+
return urljoin(self.api_url, endpoint_url)
151149

152-
url = urljoin(self.api_url, endpoint_url)
153-
154-
# Ensure the API URL ends with a trailing slash
155-
if not url.endswith('/'):
156-
url += '/'
157-
158-
return url
159150

160151
def testAuth(self):
161152
"""
@@ -169,7 +160,7 @@ def testAuth(self):
169160
return False
170161

171162
try:
172-
response = self.get('/user/me/')
163+
response = self.get('user/me/')
173164
except requests.exceptions.HTTPError as e:
174165
logger.fatal(f"Authentication error: {str(type(e))}")
175166
return False
@@ -254,7 +245,7 @@ def requestToken(self):
254245
# Request an auth token from the server
255246
try:
256247
response = self.get(
257-
'/user/token/',
248+
'user/token/',
258249
params={
259250
'name': self.token_name,
260251
}

0 commit comments

Comments
 (0)