From c779ed0bce29767249d0b5d2d26d502f1ea9566c Mon Sep 17 00:00:00 2001 From: Aileen Nowak Date: Mon, 1 Jun 2020 16:06:13 +1200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20iframe=20script=20for=20?= =?UTF-8?q?AMP=20not=20injected?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #11762 - iframe embeds which include a line break were undetected by the regex which checks for the existence and injects the required amp script - this fix updates the regex to include any non-word character, as line-breaks are not included in the general `.` token --- core/frontend/apps/amp/lib/helpers/amp_components.js | 4 ++-- test/unit/apps/amp/amp_components_spec.js | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/frontend/apps/amp/lib/helpers/amp_components.js b/core/frontend/apps/amp/lib/helpers/amp_components.js index 88fb22e3df..149f6f140f 100644 --- a/core/frontend/apps/amp/lib/helpers/amp_components.js +++ b/core/frontend/apps/amp/lib/helpers/amp_components.js @@ -24,8 +24,8 @@ function ampComponents() { components.push(''); } - let iframeCount = (html.match(/()/gi) || []).length; - let youtubeCount = (html.match(/()/gi) || []).length; + let iframeCount = (html.match(/()/gi) || []).length; + let youtubeCount = (html.match(/()/gi) || []).length; if (youtubeCount) { components.push(''); diff --git a/test/unit/apps/amp/amp_components_spec.js b/test/unit/apps/amp/amp_components_spec.js index 5698572a8a..c8eca6e396 100644 --- a/test/unit/apps/amp/amp_components_spec.js +++ b/test/unit/apps/amp/amp_components_spec.js @@ -52,8 +52,10 @@ describe('{{amp_components}} helper', function () { it('adds scripts for youtube embeds and iframes', function () { const post = { html: ` - - + + ` };