Shorten the given url.

@param string $url

@return string
492912
public function shorten($url)
    {
        $short = $this->exists($url);

        if (false !== $short) {
            return $short;
        }

        return route('shortener.show', [
            'url' => $this->hashids->encode($this->save($url)),
        ]);
    }
1195453
public function shorten($longUrl)
    {
        if ($this->urlCheck($longUrl)) {
            $request = array
            (
                'http'=> array
                (
                    'method'        =>  "POST",
                    'header'        =>  "Accept-language: en\r\n".
                                        "Content-Type: application/json\r\n",
                    'ignore_errors' => true,
                    'content'       => json_encode(array('longUrl' => $longUrl)),
                ),
                "ssl" => array(
                    "verify_peer" => false
                )
            );

            $params = (!empty($this->apiKey)) ? '?'.$this->apiKey : '';
            $data = $this->request($this->api.$params, $request);
            $data = json_decode($data,true);
            $data = $this->validate($data,'shorten');

            return $data['id'];
        }

        throw new InvalidApiResponseException('The URL provided for shortening is not valid or currently unavailable.');
    }
1082149
public static function segmentUrl($url = null)
    {
        if (!is_null($url) && !empty($url)) {
            $url = $url;
        } else {
            $url = self::requestInstance()->getRequestUrl();
        }

        return explode('/', trim($url, '/'));
    }
11010
protected function formatUrl(string $url): string
    {
        $uri = $this->urlPrefix.$url;

        return $uri === '/' ? '/' : ltrim(rtrim($uri, '/'), '/');
    }
95394
public static function trimUrl($url) {
		$result = str_replace ( "//", "/", $url );
		while ( $result !== $url ) {
			$url = $result;
			$result = str_replace ( "//", "/", $url );
		}
		return $result;
	}
311705
public function sanitize($url)
    {
        try {
            $url = Router::url($url);
        } catch (\Exception $ex) {
            return '';
        }

        if (!str_starts_with($url, '/')) {
            return $url;
        }

        if (str_starts_with($url, $this->baseUrl())) {
            $url = str_replace_once($this->baseUrl(), '', $url);
        }

        return $this->localePrefix($url);
    }
137211
public static function shorten($url)
    {
        $client = new Client();
        $request = $client->get(self::$_BITLY_URL);
        $request->getQuery()->add('access_token', self::$_ACCESS_KEY);
        $request->getQuery()->add('longUrl', $url);
        $resp = $request->send();
        $jsonRep = $resp->json();
        return $jsonRep['data']['url'];
    }
760777
protected function splitUrl($url)
    {
        $path = parse_url(trim($url, '/'), PHP_URL_PATH);
        return $path ? explode('/', $path) : array();
    }
1337000
public function shorten($url)
    {
        // make the API call through the extended client
        $response = $this->fetchUrl($this->url(), $this->parameters($url));

        // read the shorted url from the response object
        $shorter_url = $this->parse($response);

        return $shorter_url;
    }
1036290
public function expand($url)
    {
        $link = new Link;
        $link->setShortUrl($url);
        $this->provider->expand($link);
        return $link->getLongUrl();
    }
1173723
public function shorten($url)
    {
        $short = $this->bitly->shortenUrl($url);

        $this->save($url, $short);

        return $short;
    }
442424
protected function strip_base_url($url) {
        if (substr($url, 0, strlen($this->baseUrl)) == $this->baseUrl) {
            return substr($url, strlen($this->baseUrl));
        }
        return null;
    }
410668
def shorten_url(url, cols, shorten):
    
    cols = ((cols - 6) * .85)  # 6 cols for urlref and don't use while line
    if shorten is False or len(url) < cols:
        return url
    split = int(cols * .5)
    return url[:split] + "..." + url[-split:]
422970
private function getHostFromUrl($url)
    {
        if (strpos($url, '//')) {
            $url = substr($url, strpos($url, '//') + 2);
        }
        if (($p = strpos($url, '/')) !== false) {
            $url = substr($url, 0, $p);
        }
        return $url;
    }
303390
function formatUrl($url)
    {
        if (! $this->isUrl($url)) {
            return null;
        }
        $url = trim($url);
        $url = str_replace(' ', '+', $url);
        $parse = parse_url($url);
        strtolower($parse['scheme']);
        strtolower($parse['host']);
        return $this->buildUrl($parse);
    }
1127440
public static function getPathFromURL($url)
	{
		$path = str_replace(self::getProtocolFromURL($url) . '://', '', $url);
		$path = str_replace(self::getDomainFromURL($url), '', $path);
		
		if($path == '') return '/';
		
		return $path;
	}
59109
public static function removeQueryString($url) {
        $pos = strpos($url, '?');
        if ( $pos === false ) return $url;
        $url = substr($url,0,$pos);
        return $url;
    }