Mercurial > kallithea
changeset 6004:c9f97be1927e
pygrack: refactor _get_fixedpath
This function strips the repository name and any slashes from the
URL path, leaving the protocol command, like info/refs or
git-{receive,upload}-pack.
Using .split() and .strip() for this purpose isn't entirely reliable
and is entirely unreadable, so it's better to write it out, even if
it's a bit verbose.
Also, error out in the unlikely case the path doesn't start with
a slash and the repository name; that shouldn't happen normally.
author | Andrew Shadura <andrew@shadura.me> |
---|---|
date | Tue, 12 Jul 2016 21:47:14 +0200 |
parents | a90f8f33adeb |
children | 81ff11476d16 |
files | kallithea/lib/middleware/pygrack.py |
diffstat | 1 files changed, 2 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/middleware/pygrack.py Thu Jul 14 15:31:29 2016 +0200 +++ b/kallithea/lib/middleware/pygrack.py Tue Jul 12 21:47:14 2016 +0200 @@ -86,7 +86,8 @@ :param path: """ - return path.split(self.repo_name, 1)[-1].strip('/') + assert path.startswith('/' + self.repo_name + '/') + return path[len(self.repo_name) + 2:].strip('/') def inforefs(self, request, environ): """