Returns True if referring URL is the same domain as current request.

def is_internal_request(self, domain, referer):
        """
        Returns True if referring URL is the same domain as current request.

        """
        # Different subdomains are treated as different domains.
        return bool(re.match("^https?://%s/" % re.escape(domain), referer))