Beispiel #1
0
    def authority(self, authority):
        """ Authority part of this URL. """
        #Set
        if authority:
            host = authority

            # Userinfo
            match = re.search(r'^([^\@]+)\@(.+)$', authority)
            if match:
                self.userinfo = url_unescape(match.group(1))
                host = match.group(2)

            # Port
            match = re.search(r'^(.+)\:(\d+)$', host)
            if match:
                host = match.group(1)
                self.port = match.group(2)

            # Host
            host = url_unescape(host)
            match = re.search('[^\x00-\x7f]',host)
            if match:
                self.host = host.decode("idna")
                return self.ihost(host)

            self.host = host
            return self.host
Beispiel #2
0
    def parse(self, path):
        path = url_unescape(path)

        if path[0] == '/':
            self.leading_slash = True
            path = path[1:]

        if path[-1] == '/':
            self.trailing_slash = True
            path = path[:-1]

        self.parts = path.split('/')