/** * Will cleanup the hostname (some browser do not strolower the hostname), * and deal ith the hash tag on incoming URLs based on website setting. * * @param $parsedUrl * @param $idSite int|bool The site ID of the current visit. This parameter is * only used by the tracker to see if we should remove * the URL fragment for this site. * @return array */ protected static function cleanupHostAndHashTag($parsedUrl, $idSite = false) { if (empty($parsedUrl)) { return $parsedUrl; } if (!empty($parsedUrl['host'])) { $parsedUrl['host'] = Common::mb_strtolower($parsedUrl['host'], 'UTF-8'); } if (!empty($parsedUrl['fragment'])) { $parsedUrl['fragment'] = PageUrl::processUrlFragment($parsedUrl['fragment'], $idSite); } return $parsedUrl; }
private static function parseNameFromPageUrl($name, $type, $urlPrefix) { $urlRegexAfterDomain = '([^/]+)[/]?([^#]*)[#]?(.*)'; if ($urlPrefix === null) { // match url with protocol (used for outlinks / downloads) $urlRegex = '@^http[s]?://' . $urlRegexAfterDomain . '$@i'; } else { // the name is a url that does not contain protocol and www anymore // we know that normalization has been done on db level because $urlPrefix is set $urlRegex = '@^' . $urlRegexAfterDomain . '$@i'; } $matches = array(); preg_match($urlRegex, $name, $matches); if (!count($matches)) { return $name; } $urlHost = $matches[1]; $urlPath = $matches[2]; $urlFragment = $matches[3]; if (in_array($type, array(Action::TYPE_DOWNLOAD, Action::TYPE_OUTLINK))) { $path = '/' . trim($urlPath); if (!empty($urlFragment)) { $path .= '#' . $urlFragment; } return array(trim($urlHost), $path); } $name = $urlPath; if ($name === '' || substr($name, -1) == '/') { $name .= self::$defaultActionName; } $urlFragment = PageUrl::processUrlFragment($urlFragment); if (!empty($urlFragment)) { $name .= '#' . $urlFragment; } return $name; }