From 8fa3a7342ca1d9e930c200e62bcaf6f240fd21cc Mon Sep 17 00:00:00 2001 From: Duong Truong Date: Mon, 12 Aug 2019 22:32:50 +0700 Subject: [PATCH] Fix hard coded set url method while config is null (#148) --- src/SEOTools/OpenGraph.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/SEOTools/OpenGraph.php b/src/SEOTools/OpenGraph.php index 857448f..014866f 100644 --- a/src/SEOTools/OpenGraph.php +++ b/src/SEOTools/OpenGraph.php @@ -20,6 +20,13 @@ class OpenGraph implements OpenGraphContract */ protected $config; + /** + * Url property + * + * @var string + */ + protected $url = ''; + /** * Array of Properties. * @@ -275,7 +282,10 @@ protected function setupDefaults() $this->images = $value; } } elseif ($key == 'url' && $value === null) { - $this->setUrl(app('url')->current()); + $this->addProperty('url', $this->url ?: (($value === null) + ? app('url')->current() + : $this->config['defaults.url']) + ); } elseif (! empty($value) && ! array_key_exists($key, $this->properties)) { $this->addProperty($key, $value); } @@ -843,7 +853,9 @@ public function setDescription($description = null) */ public function setUrl($url) { - return $this->addProperty('url', $url); + $this->url = $url; + + return $this; } /**