diff --git a/addons/website/static/src/js/content/snippets.animation.js b/addons/website/static/src/js/content/snippets.animation.js index 8394734de8f..1fcd167c66e 100644 --- a/addons/website/static/src/js/content/snippets.animation.js +++ b/addons/website/static/src/js/content/snippets.animation.js @@ -971,8 +971,11 @@ registry.socialShare = publicWidget.Widget.extend({ _renderSocial: function (social) { var url = this.$el.data('urlshare') || document.URL.split(/[?#]/)[0]; url = encodeURIComponent(url); - var title = document.title.split(" | ")[0]; // get the page title without the company name - var hashtags = ' #' + document.title.split(" | ")[1].replace(' ', '') + ' ' + this.hashtags; // company name without spaces (for hashtag) + const titleParts = document.title.split(" | "); + const title = titleParts[0]; // Get the page title without the company name + const hashtags = titleParts.length === 1 + ? ` ${this.hashtags}` + : ` #${titleParts[1].replace(" ", "")} ${this.hashtags}`; // Company name without spaces (for hashtag) var socialNetworks = { 'facebook': 'https://www.facebook.com/sharer/sharer.php?u=' + url, 'twitter': 'https://twitter.com/intent/tweet?original_referer=' + url + '&text=' + encodeURIComponent(title + hashtags + ' - ') + url,