Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/cotter.loader.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cotter.loader.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cotter",
"version": "0.3.36-beta.5",
"version": "0.3.36",
"description": "Cotter web SDK for JavaScript",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
11 changes: 7 additions & 4 deletions src/loader/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ class Loader {
let siteCustomization = this.companyInfo?.customization?.siteCustomization || {};

let protectedPages = siteCustomization.protectedPages ?? [];
protectedPages = protectedPages.filter((el) => el.path.includes(window.location.pathname) || window.location.pathname.includes(el.path))

// protection logic
let isProtectedPage = false;
Expand All @@ -108,13 +107,17 @@ class Loader {
// if we found out that this page is a protected page, continue.
if(isProtectedPage) return;

// remove trailing and leading paths
const pagePath = page.path.replace(/^\/|\/$/g, '');
const windowPath = window.location.pathname.replace(/^\/|\/$/g, '');

switch(page.matcher) {
case "start":
let reg = new RegExp('^' + page.path, 'i')
isProtectedPage = reg.test(window.location.pathname);
let reg = new RegExp('^' + pagePath, 'i')
isProtectedPage = reg.test(windowPath);
break;
case "equal":
isProtectedPage = window.location.pathname === page.path;
isProtectedPage = windowPath === pagePath;
break;
default:
break;
Expand Down