private function rewritePathInStaticImport (Asset $asset, string $path) : string
    {
        // pass all URLs untouched, either "//..." or "schema:", where schema is a typical schema, that includes
        // http: https: and data:
        if (1 === \preg_match('~^(//|[a-z]+:)~', $path))
        {
            return $path;
        }

        $assetAtPath = $asset->getRelativeAsset($path);
        $assetAtPath = $this->cache->get($assetAtPath);

        if (null !== $assetAtPath)
        {
            // only overwrite the file name of the import
            $baseName = \basename($assetAtPath->getDumpFilePath());
            return \preg_replace('~(?<=^|/)[^/]*?$~', $baseName, $path);
        }

        return $path;
    }