Make HTTP selector extraction mirror gopher one better

This commit is contained in:
Juhani Haverinen 2015-04-26 00:15:57 +03:00
parent 8b2428ade2
commit 3673326d61
1 changed files with 5 additions and 5 deletions

View File

@ -102,19 +102,19 @@ def getselector(request): # If a HTTP request with selector is used, this extrac
if len(request) < 1:
return (request, None)
req = request[0].split('/')
while '' in req:
req.remove('')
req = request[0]
if len(req) >= 1 and req[0] == '/':
req = req[1:]
args = request[1:]
if len(req) >= 1 and req[0] in ['0', '1', '5', '9', 'g', 'h', 'I', 's']: # Supported selectors
reqpath = '/'.join(req[1:])
reqpath = req[1:]
selector = req[0]
elif len(req) == 0: # Root is by default of type 1
reqpath = '/'
selector = '1'
else:
reqpath = '/'.join(req)
reqpath = req
selector = None
return ([reqpath] + args, selector)