Skip to content

Commit a19fc66

Browse files
making changes to undecoded path
Breaking up indices to make it easier to read. Fixing edge cases around `?` and when no `?` is present.
1 parent bfd433b commit a19fc66

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

waterbutler/server/api/v1/provider/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,17 @@ async def prepare(self, *args, **kwargs):
6262

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

66+
# Find start of provider name, and start of ? marker and pull out file name from between them.
67+
provider_index = self.request.uri.index(self.path_kwargs['provider'] + '/')
68+
provider_length = (len(self.path_kwargs['provider']))
69+
end_of_path_index = self.request.uri.find('?')
70+
# If there is no ? in uri, go to end of uri
71+
if end_of_path_index == -1:
72+
end_of_path_index = len(self.request.uri)
73+
74+
self.provider.undecoded_path = self.request.uri[provider_index + provider_length: end_of_path_index]
6875
self.path = await self.provider.validate_v1_path(self.path, **self.arguments)
69-
7076
self.target_path = None
7177

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

0 commit comments

Comments
 (0)