-
Notifications
You must be signed in to change notification settings - Fork 26
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
Issue 1 #2
Issue 1 #2
Conversation
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 added one comment to your commits, thanks in advance for reviewing it.
@@ -101,7 +101,7 @@ def _prepend_prefix(self, name): | |||
prefix = self._normalize_path(prefix) | |||
if not name.startswith(prefix): | |||
name = prefix + name | |||
return name | |||
return name.replace('\\', '/') |
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 line 104 could be extracted as separate method for readability, such as:
def _convert_to_unix_path(path):
return path.replace('\\', '/')
Then it could be used at the beginning of _save
, like:
def _save(self, name, content):
name = self._convert_to_unix_path(name)
name = self._prepend_prefix(name)
content = UploadedFile(content, name)
response = self._upload(name, content)
return response['public_id']
Apart from readability, it would be a little safer as replacing backslashes with slashes at the end of _prepend_prefix
is dangerous as for example _normalize_path
would append unnecessary /
to windows style path due to if path != '' and not path.endswith('/')
condition.
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.
Very true. I'll fix that ASAP
Instead of |
I created a test case that validates the issue and added a fix.