protected function getNamePattern(array $criteria, string $extension): string
    {
        $names = [];

        $names[] = array_map(function ($criterion) use ($extension) {
            $uriExtension = URIHelper::containsExtension($criterion);
            if (! empty($extension)) {
                $extension = ltrim($extension, '.');

                if ($uriExtension === $extension) {
                    $criterion = substr($criterion,0,-strlen(".{$extension}"));
                }
            } else {
                $extension = URIHelper::containsExtension($criterion);
                if (!empty($extension)) {
                    $criterion = substr($criterion,0,-strlen(".{$extension}"));
                }
            }

            $criterion = preg_quote(URIHelper::getFilename($criterion), chr(1));

            return (empty($extension) || URIHelper::hasExtension($criterion, $extension))
                ? "{$criterion}(?:\..*?)$"
                : "{$criterion}\.{$extension}$";
        }, $criteria)[0];

        return chr(1) . implode('|', array_unique($names)) . chr(1);
    }