src/MarkdownIt/MarkdownIt.php
public function normalizeLink($url)
    {
        if( property_exists($this,'normalizeLink') && is_callable($this->normalizeLink)){
            $fn = $this->normalizeLink;
            return $fn($url);
        }
        $parsed = $this->mdurl->parse($url, true);

        if ($parsed->hostname) {
            // Encode hostnames in urls like:
            // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
            //
            // We don't encode unknown schemas, because it's likely that we encode
            // something we shouldn't (e.g. `skype:name` treated as `skype:host`)
            //
            $is = false;
            foreach (self::RECODE_HOSTNAME_FOR as &$v) {
                if( ($is = $v === $parsed->protocol) ) break;
            }
            if (empty($parsed->protocol) || $is) {
                try {
                    $parsed->hostname = $this->punycode->toASCII($parsed->hostname);
                } catch (\Exception $e) { /**/ }
            }
        }

        return $this->mdurl->encode($this->mdurl->format($parsed));
    }
public function normalizeLink($url)
    {
        if( property_exists($this,'normalizeLink') && is_callable($this->normalizeLink)){
            $fn = $this->normalizeLink;
            return $fn($url);
        }
        $parsed = $this->mdurl->parse($url, true);

        if ($parsed->hostname) {
            // Encode hostnames in urls like:
            // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
            //
            // We don't encode unknown schemas, because it's likely that we encode
            // something we shouldn't (e.g. `skype:name` treated as `skype:host`)
            //
            $is = false;
            foreach (self::RECODE_HOSTNAME_FOR as &$v) {
                if( ($is = $v === $parsed->protocol) ) break;
            }
            if (empty($parsed->protocol) || $is) {
                try {
                    $parsed->hostname = $this->punycode->toASCII($parsed->hostname);
                } catch (\Exception $e) { /**/ }
            }
        }

        return $this->mdurl->encode($this->mdurl->format($parsed));
    }
public function normalizeLink ( $ url ) { if ( property_exists ( $ this , 'normalizeLink' ) && is_callable ( $ this -> normalizeLink ) ) { $ fn = $ this -> normalizeLink ; return $ fn ( $ url ) ; } $ parsed = $ this -> mdurl -> parse ( $ url , true ) ; if ( $ parsed -> hostname ) { // Encode hostnames in urls like: // `http://host/`, `https://host/`, `mailto:user@host`, `//host/` // // We don't encode unknown schemas, because it's likely that we encode // something we shouldn't (e.g. `skype:name` treated as `skype:host`) // $ is = false ; foreach ( self :: RECODE_HOSTNAME_FOR as & $ v ) { if ( ( $ is = $ v === $ parsed -> protocol ) ) break ; } if ( empty ( $ parsed -> protocol ) || $ is ) { try { $ parsed -> hostname = $ this -> punycode -> toASCII ( $ parsed -> hostname ) ; } catch ( \ Exception $ e ) { /**/ } } } return $ this -> mdurl -> encode ( $ this -> mdurl -> format ( $ parsed ) ) ; }
Function used to encode link url to a machine-readable format,
which includes url-encoding, punycode, etc.
@param string $url
@return string
Function used to encode link url to a machine - readable format which includes url - encoding punycode etc .