示例#1
0
def urlsplit(url, scheme='', allow_fragments=True):
    """Parse a URL using urlparse.urlsplit(), splitting query and fragments.
    This function papers over Python issue9374 when needed.

    The parameters are the same as urlparse.urlsplit.
    """
    scheme, netloc, path, query, fragment = urlutils.urlsplit(
        url, scheme, allow_fragments)
    if allow_fragments and '#' in path:
        path, fragment = path.split('#', 1)
    if '?' in path:
        path, query = path.split('?', 1)
    return urlutils.SplitResult(scheme, netloc, path, query, fragment)
示例#2
0
 def test_urlunsplit(self):
     url = "http://www.yahoo.com"
     result = urlutils.urlunsplit(urlutils.urlsplit(url))
     self.assertEquals(result, 'http://www.yahoo.com')
示例#3
0
 def test_urlsplit(self):
     url = 'http://www.yahoo.com'
     result = urlutils.urlsplit(url)
     self.assertEquals(result.scheme, 'http')
示例#4
0
 def test_urlunsplit(self):
     url = "http://www.yahoo.com"
     result = urlutils.urlunsplit(urlutils.urlsplit(url))
     self.assertEqual(result, 'http://www.yahoo.com')
示例#5
0
 def test_urlsplit(self):
     url = 'http://www.yahoo.com'
     result = urlutils.urlsplit(url)
     self.assertEqual(result.scheme, 'http')