diff --git a/src/super_archives/utils/url.py b/src/super_archives/utils/url.py index a53adfd..bf40280 100644 --- a/src/super_archives/utils/url.py +++ b/src/super_archives/utils/url.py @@ -12,23 +12,13 @@ def append_to_get(path, query=None, **kwargs): def pop_from_get(path, query=None, **kwargs): - # Getting the path with the query - print query - - current_url = u'{}?{}'.format( - path, - query, - ) + query_dict = dict(urlparse.parse_qsl(query)) for key, value in kwargs.items(): - popitem = u'{}={}'.format(key, value) - if query == popitem: - return path - - if key not in current_url: - return current_url - - first_path, end_path = current_url.split(key) - end_path_without_element = end_path.split(value, 1) - path_list = first_path + end_path_without_element - print path_list - return u''.join(path_list) + if not query_dict.has_key(key): + continue + if query_dict[key] == value: + del query_dict[key] + continue + if not query_dict: + return u'{}?q='.format(path) + return u'{}?{}'.format(path, urllib.urlencode(query_dict)) -- libgit2 0.21.2