Skip to content

Commit

Permalink
making changes to undecoded path
Browse files Browse the repository at this point in the history
Breaking up indices to make it easier to read. Fixing edge cases around `?` and when no `?` is present.
  • Loading branch information
AddisonSchiller committed Sep 11, 2017
1 parent bfd433b commit a19fc66
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions waterbutler/server/api/v1/provider/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,17 @@ async def prepare(self, *args, **kwargs):

self.auth = await auth_handler.get(self.resource, provider, self.request)
self.provider = utils.make_provider(provider, self.auth['auth'], self.auth['credentials'], self.auth['settings'])
# Find start of provider name, and start of ? marker and pull out file name from between them.
self.provider.undecoded_path = self.request.uri[self.request.uri.rfind(self.path_kwargs['provider'] + '/') + (len(self.path_kwargs['provider'])): self.request.uri.rfind("?")]

# Find start of provider name, and start of ? marker and pull out file name from between them.
provider_index = self.request.uri.index(self.path_kwargs['provider'] + '/')
provider_length = (len(self.path_kwargs['provider']))
end_of_path_index = self.request.uri.find('?')
# If there is no ? in uri, go to end of uri
if end_of_path_index == -1:
end_of_path_index = len(self.request.uri)

self.provider.undecoded_path = self.request.uri[provider_index + provider_length: end_of_path_index]
self.path = await self.provider.validate_v1_path(self.path, **self.arguments)

self.target_path = None

# post-validator methods perform validations that expect that the path given in the url has
Expand Down

0 comments on commit a19fc66

Please sign in to comment.