Returns a copy of the Url instance with the specified path.

@since 1.0.0

@param UrlPathInterface $path The path.

@return UrlInterface The Url instance.
346625
public function withPath(UrlPathInterface $path): UrlInterface
    {
        return new self($this->myScheme, $this->myHost, $this->myPort, $this->myPath->withUrlPath($path), $this->myQueryString, $this->myFragment);
    }
335919
protected function getPath($path)
    {
        $hasHttp = strpos($path, 'http');
        if (false === $hasHttp || $hasHttp !== 0) {
            return $this->options['base_url'] . $path;
        }

        return $path;
    }
657118
public function getUrlFromPath($path)
    {
        $path = ltrim($path, '/');

        $host = 'https://'.($this->use_sandbox ? 'sandbox-' : '').'api.uber.com';

        return $host.($this->version ? '/'.$this->version : '').'/'.$path;
    }
227005
public static function url(string $path): string
    {
        return self::SCHEME . '://' . join(
                '/',
                array_map(
                        'rawurlencode',    // ensure singe path parts are correctly urlencoded
                        explode(
                                '/',
                                str_replace('\\', '/', $path)  // ensure correct directory separator
                        )
                )
        );
    }
921552
public function baseURL($path = '')
    {
        if (is_null($this->baseURL)) {
            $self = $_SERVER['PHP_SELF'];
            $server = $_SERVER['HTTP_HOST']
                      . rtrim(str_replace(strstr($self, 'index.php'), '', $self), '/');

            if ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')
                || !empty($_SERVER['HTTP_X_FORWARDED_PROTO'])
                && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'
            ) {
                $protocol = 'https://';
            } else {
                $protocol = 'http://';
            }

            $this->baseURL = $protocol . $server;
        }

        $url = $this->baseURL;

        if ($path !== '') {
            $url .= '/' . $path;
        }

        return $url;
    }
1160430
private function parsePath($path)
    {
        if (empty($path)) {
            $path = Map::DEFAULT_URL_DELIMITER;
        }

        // get the clean path
        return $this->urlParser->parse($path);
    }
75989
public function getUrlForRelativePath($path)
    {
        return $this->getUrlForPath(
            $this->_joinPathComponents($this->getPath(), ltrim($path, '/')));
    }
566064
protected function cloneRepository(PackageInterface $package, $path, $url)
    {
        $command = $this->getCloneCommand();
        $this->io->write("    Cloning " . $package->getSourceReference());

        $commandCallable = $this->getCloneCommandCallback($path, $package->getSourceReference(), $command);

        $this->gitUtil->runCommand($commandCallable, $url, $path, true);
        if ($url !== $package->getSourceUrl()) {
            $url = $package->getSourceUrl();
            $this->process->execute(sprintf('git remote set-url origin %s', ProcessExecutor::escape($url)), $output, $path);
        }
        $this->setPushUrl($path, $url);
        return $this;
    }
389711
protected function getObjectInstance($path)
    {
        $location = $this->applyPathPrefix($path);

        $object = $this->container->getObject($location);

        return $object;
    }
366442
public function getCopyReference($path)
    {
        //Path cannot be null
        if (is_null($path)) {
            throw new Exceptions\BoxClientException("Path cannot be null.");
        }

        //Get Copy Reference
        $response = $this->postToAPI('/files/copy_reference/get', ['path' => $path]);
        $body = $response->getDecodedBody();

        //Make and Return the Model
        return new CopyReference($body);
    }
500425
public static function isAbsolutePathReference(UriInterface $uri)
    {
        $uriPath = $uri->getPath();
        return $uri->getScheme() === ''
            && $uri->getAuthority() === ''
            && isset($uriPath[0])
            && $uriPath[0] === '/';
    }
783308
protected function buildUrlAliasDomainObject(SPIURLAlias $spiUrlAlias, string $path)
    {
        return new URLAlias(
            array(
                'id' => $spiUrlAlias->id,
                'type' => $spiUrlAlias->type,
                'destination' => $spiUrlAlias->destination,
                'languageCodes' => $spiUrlAlias->languageCodes,
                'alwaysAvailable' => $spiUrlAlias->alwaysAvailable,
                'path' => '/' . $path,
                'isHistory' => $spiUrlAlias->isHistory,
                'isCustom' => $spiUrlAlias->isCustom,
                'forward' => $spiUrlAlias->forward,
            )
        );
    }
518878
public function url($path)
    {
        $adapter = $this->driver->getAdapter();

        if ($adapter instanceof CachedAdapter) {
            $adapter = $adapter->getAdapter();
        }

        if (method_exists($adapter, 'getUrl')) {
            return $adapter->getUrl($path);
        } elseif ($adapter instanceof OssAdapter) {
            return $this->getOssUrl($adapter, $path);
        } elseif ($adapter instanceof AwsS3Adapter) {
            return $this->getAwsUrl($adapter, $path);
        } elseif ($adapter instanceof LocalAdapter) {
            return $this->getLocalUrl($path);
        } else {
            throw new RuntimeException('This driver does not support retrieving URLs.');
        }
    }
532645
public function toAbsolute(): UrlPathInterface
    {
        if ($this->myAboveBaseLevel > 0) {
            throw new UrlPathLogicException('Url path "' . $this->__toString() . '" can not be made absolute: Relative path is above base level.');
        }

        return new self(true, $this->myAboveBaseLevel, $this->myDirectoryParts, $this->myFilename);
    }
1267413
public function getRepository($path)
    {
        if (!file_exists($path) || !file_exists($path . '/.git/HEAD') && !file_exists($path . '/HEAD')) {
            throw new \RuntimeException('There is no GIT repository at ' . $path);
        }

        return new Repository($path, $this);
    }
1284479
protected function buildUrl($path)
    {
        if (!$this->laravelFS instanceof Cloud) {
            return (new Url($path))->scheme('file');
        }

        if (!$this->laravelFS instanceof FilesystemAdapter) {
            return new Url($this->laravelFS->url($path));
        }

        $adapter = $this->flysystemAdapterOrFail();

        if ($adapter instanceof Local) {
            $pathPrefix = rtrim($adapter->getPathPrefix(), '/');
            $path = trim($path, '/');
            $fullPath = $pathPrefix ? "$pathPrefix/$path" : "/$path";
            return (new Url($fullPath))->scheme('file');
        }

        return new Url($this->laravelFS->url($path));

    }
787488
public function equals(UrlPathInterface $urlPath): bool
    {
        return $this->isAbsolute() === $urlPath->isAbsolute() && $this->getDirectoryParts() === $urlPath->getDirectoryParts() && $this->getFilename() === $urlPath->getFilename();
    }