'utility method for seeing if the url is associated with
reddit as we don\'t necessarily want to mangle non-reddit
domains
returns true only if hostname is nonexistant, a subdomain of
g.domain, or a subdomain of the provided subreddit\'s cname.'

def is_reddit_url(self, subreddit=None):

    valid_subdomain = ((not self.hostname) or is_subdomain(self.hostname, g.domain) or (subreddit and subreddit.domain and is_subdomain(self.hostname, subreddit.domain)))
    if ((not valid_subdomain) or (not self.hostname) or (not g.offsite_subdomains)):
        return valid_subdomain
    return (not any((is_subdomain(self.hostname, ('%s.%s' % (subdomain, g.domain))) for subdomain in g.offsite_subdomains)))
