private function isValid($pattern, $hostname)
    {
        return 0 === strpos($pattern, '/') && (1 + strrpos($pattern, '/')) === \strlen($pattern)
            ? (bool) preg_match($pattern, $hostname)
            : fnmatch($pattern, $hostname);
    }