From 62e6e5c259d6d85c705a1fe7f1e13b139bdd64d6 Mon Sep 17 00:00:00 2001 From: curbengh <43627182+curbengh@users.noreply.github.com> Date: Wed, 25 Sep 2019 07:13:50 +0100 Subject: [PATCH] fix(open_graph): url might be null --- lib/plugins/helper/open_graph.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/plugins/helper/open_graph.js b/lib/plugins/helper/open_graph.js index 54e134dd17..8fd03f8394 100644 --- a/lib/plugins/helper/open_graph.js +++ b/lib/plugins/helper/open_graph.js @@ -78,11 +78,12 @@ function openGraphHelper(options = {}) { result += og('og:type', type); result += og('og:title', title); - if (config.pretty_urls.trailing_index === false) { - url = url.replace(/index\.html$/, ''); + if (url) { + if (config.pretty_urls.trailing_index === false) { + url = url.replace(/index\.html$/, ''); + } + url = encodeURL(url); } - - if (url) url = encodeURL(url); result += og('og:url', url); result += og('og:site_name', siteName);