From 3673326d61a6c08d9092012c1f82281fdab938f3 Mon Sep 17 00:00:00 2001 From: Juhani Haverinen Date: Sun, 26 Apr 2015 00:15:57 +0300 Subject: [PATCH] Make HTTP selector extraction mirror gopher one better --- gophersrv.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gophersrv.py b/gophersrv.py index 8724eaa..d097116 100644 --- a/gophersrv.py +++ b/gophersrv.py @@ -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)