This method call Bit.ly to shorten a given URL.
@param  unknown_type $url
@return unknown
971547
public function shortenUrl($url)
    {
        if ($this->getOptions()->getBitlyApiKey() && $this->getOptions()->getBitlyUsername()) {
            $client = new \Zend\Http\Client($this->getOptions()->getBitlyUrl());
            $client->setParameterGet(array(
                'format'  => 'json',
                'longUrl' => $url,
                'login'   => $this->getOptions()->getBitlyUsername(),
                'apiKey'  => $this->getOptions()->getBitlyApiKey(),
            ));
    
            $result = $client->send();
            if ($result) {
                $jsonResult = \Zend\Json\Json::decode($result->getBody());
                if ($jsonResult->status_code == 200) {
                    return $jsonResult->data->url;
                }
            }
        }

        return $url;
    }
679241
private function cleanUrl($url)
    {
        if (strlen($url) > 1 && strrpos($url, '/') === strlen($url) - 1) {
            $url = substr($url, 0, -1);
        }
        if (strrpos($url, '.php') === strlen($url) - 4) {
            $url = substr($url, 0, -4);
        }
        return $url;
    }
527210
public static function shortenUrl($inputUrl)
	{
		if(!self::checkInput($inputUrl)) { return false; }

		$encodedUrl = rawurlencode($inputUrl);
		$contextOptions = array(
			'ssl' => array(
				'verify_peer' => false,
				//'verify_peer' => true, // You could skip all of the trouble by changing this to false, but it's WAY uncool for security reasons.
				//'cafile' => require 'base/ssl/cacert.pem',
				//'CN_match' => 'is.gd', // Change this to your certificates Common Name (or just comment this line out if not needed)
				//'ciphers' => 'HIGH:!SSLv2:!SSLv3',
				//'disable_compression' => true,
			)
		);
		$context = stream_context_create($contextOptions);
		$shortenedUrl = file_get_contents(self::ISGD_BASIC . $encodedUrl, false, $context);

		return self::checkResult($shortenedUrl);
	}
286853
public static function getUrlWithProtocol($url) {
		if(empty($url)) {
			return $url;
		}
		list($scheme, $host) = self::splitUrl($url);
		if(empty($scheme) || empty($host)) {
			return '';
		}
		return $scheme.'://'.$host;
	}
656426
public function summarizeUrl(string $url): stdClass
    {
        $summary = $this->requester->get($this->buildUrl(['SM_URL' => $url]));

        return $this->cleanSummary($summary);
    }
854864
protected function getValueFromUrl($url)
    {
        $type = substr($url, 0, strpos($url, Ldif::KEY_VALUE_SEPARATOR));

        if (!$this->hasUrlLoader($type)) {
            $this->throwException(sprintf('Cannot find a URL loader for type "%s"', $type));
        }

        try {
            return $this->urlLoaders[$type]->load($url);
        } catch (LdifUrlLoaderException $e) {
            $this->throwException($e->getMessage());
        }
    }
1219196
protected static function getGitLabClient($url)
    {
        if (null === static::$client || static::$client->getBaseUrl() !== $url) {
            static::$client = new Client(trim($url, '/').'/');
        }

        return static::$client;
    }
417617
public static function urlContains($url)
    {
        return new static(
            function (WebDriver $driver) use ($url) {
                return mb_strpos($driver->getCurrentURL(), $url) !== false;
            }
        );
    }
547640
public function short($url)
    {
        $this->clear();
        $this->addUrl($url);
        $req = $this->out();

        if ('json' == $this->getFormat() || 'array' == $this->getFormat()) {
            return $req;
        }

        $return = $this->response;
        $this->clear();

        return $return;
    }
936870
public function shortUrl($longUrl)
    {
        $url = "https://api.weixin.qq.com/cgi-bin/shorturl?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, ['action' => 'long2short', 'long_url' => $longUrl]);
    }
916023
protected function mbParseUrl($url)
  {
    $enc_url = preg_replace_callback(
      '%[^:/@?&=#]+%usD',
      function ($matches) {
        return urlencode($matches[0]);
      },
      $url
    );

    if ($parts = parse_url($enc_url)) {
      foreach ($parts as $name => $value) {
        $parts[$name] = urldecode($value);
      }
    }

    return $parts;
  }
1253106
public function byURL($url) {
        $URL = \Convert::raw2sql($url);
        return $this->owner->filter('URLSegment', $URL)->first();
    }
662180
public static function sanitizeUrl($url)
    {
        $url = trim($url);

        if (!$url) {
            return null;
        }

        if (!preg_match("/^https?:\/\//i", $url)) {
            $url = "http://" . $url;
        }

        return self::sanitizeString($url);
    }
1038710
public function getUrlWithoutQueryString( $url )
    {
        if ( strpos( $url, '?' ) !== false )
        {
            $url = substr( $url, 0, strpos( $url, '?' ) );
        }

        return $url;
    }
407020
public function queryString($url = null)
    {
        $query = '';

        if (!$url)
        {
            $url = $this->server('request_uri');
        }

        $position = mb_strpos($url, '?');

        if ($position !== false)
        {
            $query = mb_substr($url, $position + 1);
        }

        return $query;
    }
1273389
protected function removeLastPart($url)
    {
        $shortenUrl = null;

        if ($url !== null && $url !== '') {
            // split on the / character
            $keywords = preg_split("/\//", $url);

            //if there are some words, we pop the last
            if (count($keywords) > 0) {
                array_pop($keywords);

                //rebuild the url
                $shortenUrl = implode('/', $keywords);
            }
        }

        return $shortenUrl;
    }
725477
protected function _applySort($url)
    {
        if (!$this->_sortEnabled) {
            return $url;
        }

        if (!empty($this->request->getQuery('s'))) {
            $url['?']['s'] = $this->request->getQuery('s');
        }

        if (!empty($this->request->getQuery('d'))) {
            $url['?']['d'] = $this->request->getQuery('d');
        }

        return $url;
    }