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
try refactoring path validators with regex #218
try refactoring path validators with regex #218
Conversation
Vault.validate_path can be simplified further, or even reverted to the previous version since the new regex-based one is a bit more complicated. |
solvebio/resource/object.py
Outdated
# account_domain = parts[0] | ||
# vault_name, object_path = parts[1].split('/', 1) | ||
# Clean the input: remove double slashes and leading ':' | ||
full_path = re.sub('//+', '/', full_path.lstrip(':')) |
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.
remove this
solvebio/resource/object.py
Outdated
if kwargs.get('path'): | ||
# If an override path is passed, ensure it looks like | ||
# a path (i.e. starts with a forward slash). | ||
raw_path = kwargs.get('path') |
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.
Remove this
solvebio/resource/object.py
Outdated
@@ -42,67 +42,106 @@ class Object(CreateableAPIResource, | |||
('description', 'Description'), | |||
) | |||
|
|||
# Regex describing a path within a vault. | |||
# Matching group 'path' will not contain a leading forward-slash | |||
PATH_RE = re.compile(r'^(?:[^/]*)\/(?P<path>([^/:]+/?)*)$') |
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.
adjust so path requires a starting slash
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.
FULL_PATH_RE
No description provided.