public function url(string $url = null) : self
    {
        if (! $url) {
            $url = null;

            $httpHost = getenv('APP_URL'); // Has to start with a protocol - for example "http://"!

            if ($httpHost === false) {
                $url = 'http';

                // Quick and dirty
                if (isset($_SERVER['HTTPS'])) {
                    $url .= 's';
                }

                $url .= '://';

                $httpHost = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost/';
            }  

            $requestUri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
            
            $safeRequestURI = htmlentities(strip_tags(urldecode($requestUri)));

            $url .= "{$httpHost}{$safeRequestURI}";
        } 

        if ($this->validate and ! filter_var($url, FILTER_VALIDATE_URL)) {
            throw new Exception("Open Graph: Invalid URL '{$url}'");
        }

        $this->forget('url');

        $this->tags[] = $this->createTag('url', $url);

        return $this;
    }
public function url(string $url = null) : self
    {
        if (! $url) {
            $url = null;

            $httpHost = getenv('APP_URL'); // Has to start with a protocol - for example "http://"!

            if ($httpHost === false) {
                $url = 'http';

                // Quick and dirty
                if (isset($_SERVER['HTTPS'])) {
                    $url .= 's';
                }

                $url .= '://';

                $httpHost = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost/';
            }  

            $requestUri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
            
            $safeRequestURI = htmlentities(strip_tags(urldecode($requestUri)));

            $url .= "{$httpHost}{$safeRequestURI}";
        } 

        if ($this->validate and ! filter_var($url, FILTER_VALIDATE_URL)) {
            throw new Exception("Open Graph: Invalid URL '{$url}'");
        }

        $this->forget('url');

        $this->tags[] = $this->createTag('url', $url);

        return $this;
    }
public function url ( string $ url = null ) : self { if ( ! $ url ) { $ url = null ; $ httpHost = getenv ( 'APP_URL' ) ; // Has to start with a protocol - for example "http://"! if ( $ httpHost === false ) { $ url = 'http' ; // Quick and dirty if ( isset ( $ _SERVER [ 'HTTPS' ] ) ) { $ url .= 's' ; } $ url .= '://' ; $ httpHost = isset ( $ _SERVER [ 'HTTP_HOST' ] ) ? $ _SERVER [ 'HTTP_HOST' ] : 'localhost/' ; } $ requestUri = isset ( $ _SERVER [ 'REQUEST_URI' ] ) ? $ _SERVER [ 'REQUEST_URI' ] : '' ; $ safeRequestURI = htmlentities ( strip_tags ( urldecode ( $ requestUri ) ) ) ; $ url .= "{$httpHost}{$safeRequestURI}" ; } if ( $ this -> validate and ! filter_var ( $ url , FILTER_VALIDATE_URL ) ) { throw new Exception ( "Open Graph: Invalid URL '{$url}'" ) ; } $ this -> forget ( 'url' ) ; $ this -> tags [ ] = $ this -> createTag ( 'url' , $ url ) ; return $ this ; }
Adds a URL tag

@param  string $url
@return OpenGraph
Adds a URL tag