Classes/Page/Part/MetatagPart.php
protected function setFallbackProtocol($pagePropertiesProtocol, $canonicalFallbackProtocol, $url)
    {
        $url = ltrim($url);
        if (empty($url)) {
            return null;
        }

        if (empty($canonicalFallbackProtocol)) {
            // Fallback not defined
            return $url;
        }

        if (!empty($pagePropertiesProtocol)) {
            // Protocol is well-defined via page properties (default is '0' with type string).
            // User cannot request with wrong protocol. Canonical URL cannot be wrong.
            return $url;
        }

        //get length of protocol substring
        $protocolLength = $this->getProtocolLength($url);
        if (is_null($protocolLength)) {
            //unknown protocol
            return $url;
        }

        //replace protocol prefix
        return substr_replace($url, $canonicalFallbackProtocol . '://', 0, $protocolLength);
    }
protected function setFallbackProtocol($pagePropertiesProtocol, $canonicalFallbackProtocol, $url)
    {
        $url = ltrim($url);
        if (empty($url)) {
            return null;
        }

        if (empty($canonicalFallbackProtocol)) {
            // Fallback not defined
            return $url;
        }

        if (!empty($pagePropertiesProtocol)) {
            // Protocol is well-defined via page properties (default is '0' with type string).
            // User cannot request with wrong protocol. Canonical URL cannot be wrong.
            return $url;
        }

        //get length of protocol substring
        $protocolLength = $this->getProtocolLength($url);
        if (is_null($protocolLength)) {
            //unknown protocol
            return $url;
        }

        //replace protocol prefix
        return substr_replace($url, $canonicalFallbackProtocol . '://', 0, $protocolLength);
    }
protected function setFallbackProtocol ( $ pagePropertiesProtocol , $ canonicalFallbackProtocol , $ url ) { $ url = ltrim ( $ url ) ; if ( empty ( $ url ) ) { return null ; } if ( empty ( $ canonicalFallbackProtocol ) ) { // Fallback not defined return $ url ; } if ( ! empty ( $ pagePropertiesProtocol ) ) { // Protocol is well-defined via page properties (default is '0' with type string). // User cannot request with wrong protocol. Canonical URL cannot be wrong. return $ url ; } //get length of protocol substring $ protocolLength = $ this -> getProtocolLength ( $ url ) ; if ( is_null ( $ protocolLength ) ) { //unknown protocol return $ url ; } //replace protocol prefix return substr_replace ( $ url , $ canonicalFallbackProtocol . '://' , 0 , $ protocolLength ) ; }
Replaces protocol in URL with a fallback protocol
Missing or unknown protocol will not be replaced

@param string $pagePropertiesProtocol protocol from page properties
@param string $canonicalFallbackProtocol fallback protocol to go for if protocol in page properties is undefined
@param string $url

@return string|null
Replaces protocol in URL with a fallback protocol Missing or unknown protocol will not be replaced