-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove creating double slash in url #327
base: master
Are you sure you want to change the base?
Conversation
lib/vsc/utils/rest.py
Outdated
@@ -215,6 +215,8 @@ def get_connection(self, method, url, body, headers): | |||
sep = '/' | |||
else: | |||
sep = '' | |||
if self.url.endswith('/') and url.startswith('/'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what url are you trying to parse here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matesaki i'm mainly puzzled why the code above does work.
also add a unittest for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Condition above check if there is no slash before merging. If true, add one.
This new condition check if there are to many slashes. If true, remove one.
It may be confusing because there are two variables url, first Ends with '/' and second Starts with '/'.
Trying to make a test ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't know how to test it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think the whole code block, incl the previous lines can become
url = url.lstrip('/')
if self.url.endswith('/'):
sep = ''
else:
sep = '/'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, this is equivalent
(rebased)
When I running scripts form vsc-ugent.git, then in get_connection() function I got: |
Merging domain url and path url create double slash which causes on localhost error 404 (Page not found). Signed-off-by: Martin Sakin <marty@inuits.eu>
Merging domain url and path url creates double slash
which causes on localhost error 404 (Page not found).
Signed-off-by: Martin Sakin marty@inuits.eu