From 82c4393fd025f9ab50197c0d68d52f57eb55ded2 Mon Sep 17 00:00:00 2001 From: "Julien (juc) Castiaux" Date: Mon, 18 Mar 2019 14:28:56 +0000 Subject: [PATCH] [FIX] website: facebook page id regexp Some valid facebook pages appear as broken by the preview although they load perfectly fine afterward. At facebook, an id is required to perform requests to their graphql endpoints. The ID is part of the URL of the page, sometime (like Odoo) the ID is the name of the page and sometime (like LACME France) it is a generated 9-digits id shown in the URL after the name of the page. Example of two valid page URL and their page ID: https://www.facebook.com/Odoo ^^^^ ---- https://www.facebook.com/LACME-France-910072559192969 ^^^^^^^^^^^^^^^ ---------------------------- `^` denotes the page id and what odoo uses as page id after the commit `-` denotes what odoo used as page id before the commit opw-19494444 closes odoo/odoo#31922 Signed-off-by: Julien Castiaux --- addons/website/static/src/js/editor/snippets.options.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js index 3d79951cf70..3f0e570b38d 100644 --- a/addons/website/static/src/js/editor/snippets.options.js +++ b/addons/website/static/src/js/editor/snippets.options.js @@ -642,11 +642,11 @@ var FacebookPageDialog = weWidgets.Dialog.extend({ */ _renderPreview: function () { var self = this; - var match = this.fbData.href.match(/^(?:https?:\/\/)?(?:www\.)?(?:fb|facebook)\.com\/(\w+)/); + var match = this.fbData.href.match(/^(?:https?:\/\/)?(?:www\.)?(?:fb|facebook)\.com\/(?:([\w.]+)|[^/?#]+-([0-9]{15,16}))(?:$|[\/?# ])/); if (match) { // Check if the page exists on Facebook or not $.ajax({ - url: 'https://graph.facebook.com/' + match[1] + '/picture', + url: 'https://graph.facebook.com/' + (match[2] || match[1]) + '/picture', statusCode: { 200: function () { self._toggleWarning(true);