fix share url

This commit is contained in:
Alex Grintsvayg 2016-10-24 18:54:17 -04:00
parent 75e0d7ca80
commit ff541f7ac1
2 changed files with 13 additions and 3 deletions

View file

@ -80,6 +80,16 @@ class Request
return static::getHttpHeader('Host') ? rtrim(static::getHttpHeader('Host'), '.') : '';
}
public static function getHostAndProto(): string
{
return (static::isSSL() ? 'https' : 'http') . '://' . static::getHost();
}
public static function isSSL(): bool
{
return static::getHeader('HTTPS') || strtolower(static::getHttpHeader('X_FORWARDED_PROTO')) == 'https';
}
public static function getServerName(): string
{
return static::getHeader('SERVER_NAME');

View file

@ -1,4 +1,4 @@
<?php $url = urlencode(Request::getHost() . $post->getRelativeUrl()) ?>
<?php $url = urlencode(Request::getHostAndProto() . '/' . $post->getRelativeUrl()) ?>
<?php $title = urlencode($post->getTitle()) ?>
<div class="social-share-buttons">
<a href="https://www.facebook.com/sharer/sharer.php?u=<?php echo $url ?>&t=<?php echo $title ?>" title="Share on Facebook" target="_blank">