public static function replaceDirname($uri, $path)
    {
        $uri = self::filterUri($uri);

        return self::normalizePath($uri, (new HierarchicalPath($uri->getPath()))->withDirname($path));
    }