@massimo-cassandro/minimo 0.12.12 → 0.12.13
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,32 @@ 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
|
+
|
|
405
|
+
if (!Array.isArray(allowed) || !allowed.length || !document.referrer) {
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
|
|
395
409
|
const referrerPath = new URL(document.referrer).pathname;
|
|
396
|
-
|
|
410
|
+
|
|
411
|
+
// Ritorna true se il path del referrer è contenuto in una delle stringhe di 'allowed'
|
|
412
|
+
return allowed.some(allowedUrl =>
|
|
413
|
+
typeof allowedUrl === 'string' && allowedUrl.includes(referrerPath)
|
|
414
|
+
);
|
|
397
415
|
}
|
|
398
416
|
|
|
417
|
+
|
|
399
418
|
/** Salva la pagina corrente nel cookie di sessione `sd-pag`. */
|
|
400
419
|
_savePageCookie(page) {
|
|
401
420
|
document.cookie = `sd-pag=${page}; path=${location.pathname}`;
|
|
@@ -721,7 +740,7 @@ class SimpleDatatableAdapter extends HTMLElement {
|
|
|
721
740
|
.forEach(btn => btn.classList.add(styles.hasSvg));
|
|
722
741
|
|
|
723
742
|
// Ripristino pagina dal cookie di sessione (se referrer autorizzato)
|
|
724
|
-
if (this.
|
|
743
|
+
if (this._isReferrer()) {
|
|
725
744
|
const savedPage = this._readPageCookie();
|
|
726
745
|
if (savedPage !== null) {
|
|
727
746
|
this._dt.page(savedPage);
|