def _update_redirect_uri(base_redirect_uri, params, as_fragment=False): parsed = UrlParser(base_redirect_uri) if as_fragment: parsed.fragment = urlencode(params) else: parsed.update_query(**params) return parsed.unparse()
def make_anchored_permalink(self, link=None, sr=None, context=1, anchor=None): if link: permalink = UrlParser(self.make_permalink(link, sr)) else: permalink = UrlParser(self.make_permalink_slow()) permalink.update_query(context=context) permalink.fragment = anchor if anchor else self._id36 return permalink.unparse()
def test_same_url(self): u = UrlParser('http://example.com:8000/a;b?foo=bar&bar=baz#spam') u2 = UrlParser('http://example.com:8000/a;b?bar=baz&foo=bar#spam') self.assertEquals(u, u2) u3 = UrlParser('') u3.scheme = 'http' u3.hostname = 'example.com' u3.port = 8000 u3.path = '/a' u3.params = 'b' u3.update_query(foo='bar', bar='baz') u3.fragment = 'spam' self.assertEquals(u, u3)