protected static function decode(string $component, string $allowed): string
    {
        $allowed = sprintf('/[%s]/', $allowed);
        $encoded = sprintf('/%s/', static::PCT_ENCODED_SET);

        return preg_replace_callback($encoded, function ($matches) use ($allowed) {
            $char = rawurldecode($matches[0]);

            if (preg_match($allowed, $char)) {
                return $char;
            }

            return strtoupper($matches[0]);
        }, $component);
    }