Skip to content

Commit

Permalink
Merge pull request #153 from PrestaSafe/3.0.1
Browse files Browse the repository at this point in the history
Fix HTTP_SEC_FETCH_DEST not detected
  • Loading branch information
PrestaSafe authored Oct 26, 2023
2 parents 2eb537c + 6402b44 commit 821608b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
11 changes: 9 additions & 2 deletions _dev/src/components/Iframe.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
</script>

Expand All @@ -83,9 +91,8 @@ let showLoader = computed(() => {
<section class="w-full h-full">
<!-- <button @click="reloadIframe()"> reload iframe </button> {{ showLoader }} -->
<!-- {{ classes }} -->

<iframe id="website-iframe" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
:class="[height, width, showLoader ? 'opacity-50' : '']" class="border-none h-full mx-auto rounded" :src="iframe.current_url.value"
:class="[height, width, showLoader ? 'opacity-50' : '']" class="border-none h-full mx-auto rounded" :src="filteredURL"
frameborder="0"></iframe>
<Loader :visible="showLoader" class="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2">
Chargement en cours</Loader>
Expand Down
13 changes: 12 additions & 1 deletion _dev/src/scripts/iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions prettyblocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/';
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 821608b

Please sign in to comment.