Skip to content
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

Merged
merged 9 commits into from Jan 11, 2018

Conversation

davecap
Copy link
Member

@davecap davecap commented Jan 8, 2018

No description provided.

@davecap davecap requested a review from jsh2134 January 8, 2018 21:15
@davecap
Copy link
Member Author

davecap commented Jan 8, 2018

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.

# 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(':'))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this

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')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this

@@ -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>([^/:]+/?)*)$')
Copy link
Member Author

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FULL_PATH_RE

@davecap davecap merged commit c3c4383 into f-update-import-shortcuts Jan 11, 2018
@davecap davecap deleted the f-path-processing-refactor branch January 11, 2018 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant