Make HTTP selector extraction mirror gopher one better
This commit is contained in:
parent
8b2428ade2
commit
3673326d61
10
gophersrv.py
10
gophersrv.py
|
@ -102,19 +102,19 @@ def getselector(request): # If a HTTP request with selector is used, this extrac
|
||||||
if len(request) < 1:
|
if len(request) < 1:
|
||||||
return (request, None)
|
return (request, None)
|
||||||
|
|
||||||
req = request[0].split('/')
|
req = request[0]
|
||||||
while '' in req:
|
if len(req) >= 1 and req[0] == '/':
|
||||||
req.remove('')
|
req = req[1:]
|
||||||
args = request[1:]
|
args = request[1:]
|
||||||
|
|
||||||
if len(req) >= 1 and req[0] in ['0', '1', '5', '9', 'g', 'h', 'I', 's']: # Supported selectors
|
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]
|
selector = req[0]
|
||||||
elif len(req) == 0: # Root is by default of type 1
|
elif len(req) == 0: # Root is by default of type 1
|
||||||
reqpath = '/'
|
reqpath = '/'
|
||||||
selector = '1'
|
selector = '1'
|
||||||
else:
|
else:
|
||||||
reqpath = '/'.join(req)
|
reqpath = req
|
||||||
selector = None
|
selector = None
|
||||||
|
|
||||||
return ([reqpath] + args, selector)
|
return ([reqpath] + args, selector)
|
||||||
|
|
Loading…
Reference in New Issue