Graby\Extractor\HttpClient::cleanupUrl PHP Method

cleanupUrl() private method

Cleanup URL and retrieve the final url to be called.
private cleanupUrl ( string $url ) : string
$url string
return string
    private function cleanupUrl($url)
    {
        // rewrite part of urls to something more readable
        foreach ($this->config['rewrite_url'] as $find => $action) {
            if (strpos($url, $find) !== false && is_array($action)) {
                $url = strtr($url, $action);
            }
        }
        // convert fragment to actual query parameters
        if ($fragmentPos = strpos($url, '#!')) {
            $fragment = parse_url($url, PHP_URL_FRAGMENT);
            // strip '!'
            $fragment = substr($fragment, 1);
            $query = array('_escaped_fragment_' => $fragment);
            // url without fragment
            $url = substr($url, 0, $fragmentPos);
            $url .= parse_url($url, PHP_URL_QUERY) ? '&' : '?';
            // needed for some sites
            $url .= str_replace('%2F', '/', http_build_query($query));
        }
        // remove fragment
        if ($pos = strpos($url, '#')) {
            $url = substr($url, 0, $pos);
        }
        return $url;
    }