manipulate the Current/Given URL with the given parameters
@param $changes
@param  $url
@return string
356355
protected function url_modify($changes, $url)
	{
		// Parse the url into pieces
		$url_array = parse_url($url);

		// The original URL had a query string, modify it.
		if (!empty($url_array['query'])) {
			parse_str($url_array['query'], $query_array);
			$query_array = array_merge($query_array, $changes);
		} // The original URL didn't have a query string, add it.
		else {
			$query_array = $changes;
		}

		return (!empty($url_array['scheme']) ? $url_array['scheme'] . '://' : null) .
		(!empty($url_array['host']) ? $url_array['host'] : null) .
		(!empty($url_array['port']) ? ':' . $url_array['port'] : null) .
		$url_array['path'] . '?' . http_build_query($query_array);
	}
333273
protected function normalizeUrl($url, array $parameters = [])
    {
        $normalizedUrl = $url;
        if (!empty($parameters)) {
            $normalizedUrl .= (false !== strpos($url, '?') ? '&' : '?').http_build_query($parameters, '', '&');
        }

        return $normalizedUrl;
    }
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;
    }
98633
protected function setProtocolToHttps($url)
    {
        $processUrl = trim($url);
        if (strpos($url, 'http://') === 0) {
            $processUrl = substr($processUrl, 7);
        } elseif (strpos($processUrl, 'https://') === 0) {
            $processUrl = substr($processUrl, 8);
        } elseif (strpos($processUrl, '//') === 0) {
            $processUrl = substr($processUrl, 2);
        }
        return 'https://' . $processUrl;
    }
1073144
private function buildUrl($url, $parameters)
    {
        $prams_former = '?';

        foreach ($parameters as $key => $value) {
            $prams_former = $prams_former.$key.'='.$value.'&';
        }

        return $url.substr($prams_former, 0, -1);
    }
1132487
protected function _fixUrlForParsing($url)
    {
        $path = $url->path;

        //bug in request
        if ($url->format == 'php') {
            $path .= '.php';
            $url->format = null;
        }

        $path = substr_replace($path, '', 0, strlen($this->_base_url->path));
        $path = preg_replace('/index\/?.php/', '', $path);
        $path = trim($path, '/');

        $url->path = $path;
        $url->format = $url->format ? $url->format : pick(AnRequest::format(), 'html');

        if (! empty($url->format)) {
            $url->query['format'] = $url->format;
        }
    }
775540
function (url) {
		var current = this.current, params = current.params;

		var state = find(url);

		if (state.is_changed(current.name, params)) {
			this.current = state;
			this.trigger_event("state_changed", state);
			this.trigger_event("state_changed_success", url);
		}
	}
537372
static public function urlAppend(string $url, array $params): string
    {
        // 如果已经有参数,附加&,否则附加?
        if (!strpos($url, '?')) {
            $url .= "?";
        } else {
            $url .= "&";
        }

        // 逐个参数附加
        foreach ($params as $k => $v) {
            $url .= "$k=$v&";
        }

        // 去掉最后的&
        $url = trim($url, '&');

        // 返回新的URL
        return $url;
    }
239347
public function request($url, $options)
    {
        $this->url = $url;
        $this->options = array_replace_recursive($this->settings['defaults'], $options);

        try {
            return $this->handleRequest();
        } catch (TokenExpiredException $e) {
            $this->refresh();

            return $this->handleRequest();
        }
    }
802989
public function takeChanges($changes)
    {
        $result = null;
        if (!is_array($changes)) {
            \Ease\Shared::logger()->addToLog(_('Empty WebHook request'),
                'Warning');
        } else {
            if (array_key_exists('winstrom', $changes)) {
                $this->globalVersion = intval($changes['winstrom']['@globalVersion']);
                $this->changes       = $changes['winstrom']['changes'];
            }
            $result = is_numeric($changes['winstrom']['next']) ? $changes['winstrom']['next']-1 : $this->globalVersion;
        }
        return $result;
    }
712364
private static function cleanUrl($url)
    {
        $result = '';
        $inner = false;

        for ($i = 0; $i < strlen($url); $i++) {
            if (!$inner) {
                if ($url[$i] != '{') {
                    $result .= $url[$i];
                } else {
                    $result .= '{';
                    $inner = true;
                }
            } else {
                if ($url[$i] == '}') {
                    $result .= '}';
                    $inner = false;
                }
            }
        }

        return $result;
    }
791171
public function back($actions='insert|update|do_delete', $url="")
    {

        if ($url == "") {
            if (count($this->links)) {
                $url = array_pop($this->links);
            } else {
                return $this;
            }
        } else {
            $base = str_replace(Request::path(),'',strtok(Request::fullUrl(),'?'));
            $match_url = str_replace($base, '/', strtok($url,'?'));
            if (Request::path()!= $match_url) {
                $url = Persistence::get($match_url);
            }
        }

        $this->back_on = explode("|", $actions);
        $this->back_url = $url;

        return $this;
    }
672454
public function addUrl($location, $priority = 0.5, $lastModification = null, $changeFrequency = null)
    {
        $urlElement = $this->createElement('url');

        if (0 === strpos($location, '/')) {
            $location = $this->baseUri.$location;
        }
        $locElement = $this->createElement('loc');
        $locElement->appendChild($this->createTextNode($location));
        $urlElement->appendChild($locElement);

        $priorityElement = $this->createElement('priority');
        $priorityElement->appendChild($this->createTextNode((string) round($priority, 1)));
        $urlElement->appendChild($priorityElement);

        if (null !== $lastModification) {
            if ($lastModification instanceof \DateTime) {
                $lastModification = $lastModification->format('c');
            } else {
                if (is_string($lastModification)) {
                    $lastModification = strtotime($lastModification);
                }
                $lastModification = date('c', $lastModification);
            }

            $lastmodElement = $this->createElement('lastmod');
            $lastmodElement->appendChild($this->createTextNode($lastModification));
            $urlElement->appendChild($lastmodElement);
        }

        if (null !== $changeFrequency && in_array($changeFrequency, static::$frequency, true)) {
            $changefreqElement = $this->createElement('changefreq');
            $changefreqElement->appendChild($this->createTextNode($changeFrequency));
            $urlElement->appendChild($changefreqElement);
        }

        $this->root->appendChild($urlElement);

        return $this;
    }
354041
final static function normalize(string $url):string{#{{{

    if(isset(
      $_SERVER['REQUEST_SCHEME'],
      $_SERVER['REQUEST_HOST'],
      $_SERVER['REQUEST_PORT'],
      $_SERVER['REQUEST_URI'],
      $_SERVER['SERVER_PORT']
    ) || PHP_SAPI ==='cli')
      return $url;

    $arr = parse_url($url);
    if($arr===false) return '';

    $a = [
      $arr['scheme']??$_SERVER['REQUEST_SCHEME'],
      '://',
      $arr['user']??'',
      ':',
      $arr['pass']??'',
      '@',
      $arr['host']??$_SERVER['HTTP_HOST'],
      ':',
      $arr['port']??$_SERVER['SERVER_PORT'],
      substr($_SERVER['REQUEST_URI'],0, strrpos($_SERVER['REQUEST_URI'],'/')+1),
      $arr['path']??'',
      '?',
      $arr['query']??'',
      '#',
      $arr['fragment']??'',
    ];

    if(!in_array($a[0], ['http','https'])) return '';

    if($a[12]==='')            unset($a[11],$a[12]);
    if($a[14]==='')            unset($a[13],$a[14]);
    if($a[8]==80)              unset($a[7],$a[8]);
    if($a[4]==='')             unset($a[3],$a[4]);
    if($a[2]==='')             unset($a[2],$a[3],$a[4],$a[5]);
    if(strpos($a[10],'/')===0) unset($a[9]);

    while(strpos($a[10],'../')===0){
      $a[10] = substr($a[10],3);
      $a[9] = dirname($a[9]);
      if($a[9]!=='/') $a[9] .= '/';
    }

    while(strpos($a[10],'./')===0){
      $a[10] = substr($a[10],2);
    }

    if($a[10]==='.') unset($a[10]);

    return implode($a);
  }
514504
private function addToUrl($parameters)
    {
        /** @var AddToUrlEvent $urlAfter */
        $urlAfter = $this->eventDispatcher->dispatch(ContaoEvents::BACKEND_ADD_TO_URL, new AddToUrlEvent($parameters));

        return $urlAfter->getUrl();
    }
832955
public function url($url, $parameters = [])
    {
        $this->url = $url;
        $this->parameters = $parameters;

        return $this;
    }
95394
public static function trimUrl($url) {
		$result = str_replace ( "//", "/", $url );
		while ( $result !== $url ) {
			$url = $result;
			$result = str_replace ( "//", "/", $url );
		}
		return $result;
	}