public static function addBasepath($uri, $path)
    {
        self::filterUri($uri);
        $currentpath = $uri->getPath();
        if ('' !== $currentpath && '/' !== $currentpath[0]) {
            $currentpath = '/'.$currentpath;
        }

        $path = (new HierarchicalPath($path))->withLeadingSlash();
        if (0 === strpos($currentpath, (string) $path)) {
            return $uri->withPath($currentpath);
        }

        return $uri->withPath((string) $path->append($currentpath));
    }