From 6402b44c73031955c95e72c462a597416777b2eb Mon Sep 17 00:00:00 2001 From: Prestasafe Date: Thu, 26 Oct 2023 17:16:57 +0200 Subject: [PATCH] Fix HTTP_SEC_FETCH_DEST not detected --- _dev/src/components/Iframe.vue | 11 +++++++++-- _dev/src/scripts/iframe.js | 13 ++++++++++++- prettyblocks.php | 4 ++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/_dev/src/components/Iframe.vue b/_dev/src/components/Iframe.vue index 4e889bdc..af5f830a 100644 --- a/_dev/src/components/Iframe.vue +++ b/_dev/src/components/Iframe.vue @@ -75,6 +75,14 @@ let showLoader = computed(() => { }) watch(iframe.loader); +let filteredURL = computed(() => { + return iframe.updateFilteredURL(iframe.current_url.value) +}) + + +watch(iframe.current_url, () => { + filteredURL.value = iframe.updateFilteredURL(iframe.current_url.value) +}) @@ -83,9 +91,8 @@ let showLoader = computed(() => {
- Chargement en cours diff --git a/_dev/src/scripts/iframe.js b/_dev/src/scripts/iframe.js index bd3a9e94..8f2aca68 100644 --- a/_dev/src/scripts/iframe.js +++ b/_dev/src/scripts/iframe.js @@ -143,10 +143,21 @@ export default class Iframe { async reloadIframe() { this.loader.value = true let iframe = document.getElementById('website-iframe') - iframe.src = this.current_url.value + iframe.src = this.updateFilteredURL(this.current_url.value) // this.loadIframe() // this.loader.value = false } + updateFilteredURL(url) { + let hashIndex = url.indexOf('#'); + if (hashIndex !== -1) { + url = url.substring(0, hashIndex) + '?prettyblocks=1' + url.substring(hashIndex); + } else if (!url.includes('?')) { + url += '?prettyblocks=1'; + } else if (!url.includes('prettyblocks')) { + url += '&prettyblocks=1'; + } + return url; + } /** * trigger popup with blocks choice on Click diff --git a/prettyblocks.php b/prettyblocks.php index e47dbeca..8eb5bbb6 100755 --- a/prettyblocks.php +++ b/prettyblocks.php @@ -58,7 +58,7 @@ public function __construct() { $this->name = 'prettyblocks'; $this->tab = 'administration'; - $this->version = '3.0.0'; + $this->version = '3.0.1'; $this->author = 'PrestaSafe'; $this->need_instance = 1; $this->js_path = $this->_path . 'views/js/'; @@ -207,7 +207,7 @@ public function getWidgetVariables($hookName = null, array $configuration = []) public function hookdisplayHeader($params) { - if ($_SERVER['HTTP_SEC_FETCH_DEST'] == 'iframe') { + if ((isset($_SERVER['HTTP_SEC_FETCH_DEST']) && $_SERVER['HTTP_SEC_FETCH_DEST'] == 'iframe') || \Tools::getValue('prettyblocks') === '1') { $this->context->controller->registerJavascript( 'prettyblocks', 'modules/' . $this->name . '/views/js/build.js',