@massimo-cassandro/minimo 0.12.12 → 0.12.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -389,13 +389,30 @@ class SimpleDatatableAdapter extends HTMLElement {
|
|
|
389
389
|
* Restituisce true se il referrer corrisponde a uno dei percorsi in `refs`.
|
|
390
390
|
* Il confronto avviene su `pathname` per ignorare query string e hash.
|
|
391
391
|
*/
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
392
|
+
_isReferrer() {
|
|
393
|
+
let allowed = this._getParam('refs', []);
|
|
394
|
+
|
|
395
|
+
if (typeof allowed === 'string') {
|
|
396
|
+
try {
|
|
397
|
+
allowed = JSON.parse(allowed);
|
|
398
|
+
} catch (e) {
|
|
399
|
+
// eslint-disable-next-line no-console
|
|
400
|
+
console.error('[s-datatable] Errore nel parsing di \'refs\':', e);
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
if (!Array.isArray(allowed) || !allowed.length || !document.referrer) {
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
395
407
|
const referrerPath = new URL(document.referrer).pathname;
|
|
396
|
-
|
|
408
|
+
|
|
409
|
+
// Ritorna true se il path del referrer è contenuto in una delle stringhe di 'allowed'
|
|
410
|
+
return allowed.some(allowedUrl =>
|
|
411
|
+
(typeof allowedUrl === 'string') && (referrerPath.includes(allowedUrl))
|
|
412
|
+
);
|
|
397
413
|
}
|
|
398
414
|
|
|
415
|
+
|
|
399
416
|
/** Salva la pagina corrente nel cookie di sessione `sd-pag`. */
|
|
400
417
|
_savePageCookie(page) {
|
|
401
418
|
document.cookie = `sd-pag=${page}; path=${location.pathname}`;
|
|
@@ -721,7 +738,7 @@ class SimpleDatatableAdapter extends HTMLElement {
|
|
|
721
738
|
.forEach(btn => btn.classList.add(styles.hasSvg));
|
|
722
739
|
|
|
723
740
|
// Ripristino pagina dal cookie di sessione (se referrer autorizzato)
|
|
724
|
-
if (this.
|
|
741
|
+
if (this._isReferrer()) {
|
|
725
742
|
const savedPage = this._readPageCookie();
|
|
726
743
|
if (savedPage !== null) {
|
|
727
744
|
this._dt.page(savedPage);
|