@chat21/chat21-web-widget 5.1.0-rc14 → 5.1.0-rc17
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/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,13 @@
|
|
|
6
6
|
### **Copyrigth**:
|
|
7
7
|
*Tiledesk SRL*
|
|
8
8
|
|
|
9
|
+
# 5.1.0-rc17
|
|
10
|
+
- **added**: allowedOnSpecificUrl and allowedOnSpecificUrlList to manage list of pattern url to allow to load the widget
|
|
11
|
+
|
|
12
|
+
# 5.1.0-rc16
|
|
13
|
+
- **added**: hideOnSpecificUrlList replaced in favour of hideOnSpecificDomainList
|
|
14
|
+
|
|
15
|
+
# 5.1.0-rc15
|
|
9
16
|
# 5.1.0-rc14
|
|
10
17
|
- **added**: ability to hide widget on selected domains based on hideOnSpecificDomainList variable
|
|
11
18
|
|
package/package.json
CHANGED
package/src/app/app.component.ts
CHANGED
|
@@ -265,7 +265,7 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
|
265
265
|
//check if allowed to load
|
|
266
266
|
let canLoad = this.globalSettingsService.manageLoadingDomains();
|
|
267
267
|
if(!canLoad){
|
|
268
|
-
|
|
268
|
+
console.error('[Check canLoad] Widget is not able to load on this domain!!!')
|
|
269
269
|
this.hideWidget()
|
|
270
270
|
this.disposeWidget();
|
|
271
271
|
}
|
package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.ts
CHANGED
|
@@ -539,7 +539,7 @@ export class ConversationFooterComponent implements OnInit, OnChanges {
|
|
|
539
539
|
}
|
|
540
540
|
|
|
541
541
|
checkForUrlDomain(text){
|
|
542
|
-
if(this.project && this.project.settings?.allowed_urls === true){
|
|
542
|
+
if(this.project && this.project.settings?.allowed_urls === true && this.project.settings?.allowed_urls_list){
|
|
543
543
|
this.showAlertUrl = !isAllowedUrlInText(text, this.project.settings?.allowed_urls_list);
|
|
544
544
|
if(this.showAlertUrl){
|
|
545
545
|
return false
|
|
@@ -516,8 +516,11 @@ export class GlobalSettingsService {
|
|
|
516
516
|
if (variables.hasOwnProperty('showAudioRecorderFooterButton')) {
|
|
517
517
|
globals['showAudioRecorderFooterButton'] = variables['showAudioRecorderFooterButton'];
|
|
518
518
|
}
|
|
519
|
-
if (variables.hasOwnProperty('
|
|
520
|
-
globals['
|
|
519
|
+
if (variables.hasOwnProperty('allowedOnSpecificUrl')) {
|
|
520
|
+
globals['allowedOnSpecificUrl'] = variables['allowedOnSpecificUrl'];
|
|
521
|
+
}
|
|
522
|
+
if (variables.hasOwnProperty('allowedOnSpecificUrlList')) {
|
|
523
|
+
globals['allowedOnSpecificUrlList'] = variables['allowedOnSpecificUrlList'];
|
|
521
524
|
}
|
|
522
525
|
|
|
523
526
|
}
|
|
@@ -1974,11 +1977,28 @@ export class GlobalSettingsService {
|
|
|
1974
1977
|
}
|
|
1975
1978
|
|
|
1976
1979
|
manageLoadingDomains(): boolean {
|
|
1977
|
-
|
|
1980
|
+
|
|
1981
|
+
if(this.globals.allowedOnSpecificUrl && (!this.globals.allowedOnSpecificUrlList || this.globals.allowedOnSpecificUrlList.length === 0) ){
|
|
1982
|
+
console.log('allowedOnSpecificUrl is true and allowedOnSpecificUrlList is empty or not set');
|
|
1978
1983
|
return true
|
|
1979
1984
|
}
|
|
1980
|
-
|
|
1981
|
-
|
|
1985
|
+
|
|
1986
|
+
function wildcardToRegex(pattern: string): RegExp {
|
|
1987
|
+
// Escape caratteri speciali della regex, tranne * che poi sostituiremo
|
|
1988
|
+
const escaped = pattern.replace(/[-/\\^+?.()|[\]{}]/g, '\\$&');
|
|
1989
|
+
// Sostituisci * con .*
|
|
1990
|
+
const regexPattern = '^' + escaped.replace(/\*/g, '.*') + '$';
|
|
1991
|
+
return new RegExp(regexPattern);
|
|
1992
|
+
}
|
|
1993
|
+
|
|
1994
|
+
const currentUrl = this.globals.windowContext.location.href;
|
|
1995
|
+
const shouldShow = this.globals.allowedOnSpecificUrlList.some(pattern => {
|
|
1996
|
+
const regex = wildcardToRegex(pattern);
|
|
1997
|
+
return regex.test(currentUrl);
|
|
1998
|
+
});
|
|
1999
|
+
|
|
2000
|
+
// let isAllowedToLoad = !isAllowedUrlInText(this.globals.windowContext.location.origin, this.globals.hideOnSpecificDomainList)
|
|
2001
|
+
return shouldShow
|
|
1982
2002
|
}
|
|
1983
2003
|
|
|
1984
2004
|
}
|
package/src/app/utils/globals.ts
CHANGED
|
@@ -219,7 +219,8 @@ export class Globals {
|
|
|
219
219
|
showAttachmentFooterButton: boolean // ******* new ********
|
|
220
220
|
showAudioRecorderFooterButton: boolean // ******* new ********
|
|
221
221
|
|
|
222
|
-
|
|
222
|
+
allowedOnSpecificUrl: boolean // ******* new ********
|
|
223
|
+
allowedOnSpecificUrlList: Array<string> // ******* new ********
|
|
223
224
|
constructor(
|
|
224
225
|
) { }
|
|
225
226
|
|
|
@@ -419,8 +420,10 @@ export class Globals {
|
|
|
419
420
|
this.showAttachmentFooterButton = true;
|
|
420
421
|
/** show/hide rec audio option in footer chat-detail page */
|
|
421
422
|
this.showAudioRecorderFooterButton = true;
|
|
422
|
-
/** set a list of
|
|
423
|
-
this.
|
|
423
|
+
/** enabled to set a list of pattern url able to load the widget **/
|
|
424
|
+
this.allowedOnSpecificUrl = false
|
|
425
|
+
/** set a list of pattern url able to load the widget */
|
|
426
|
+
this.allowedOnSpecificUrlList = [];
|
|
424
427
|
|
|
425
428
|
// ============ END: SET EXTERNAL PARAMETERS ==============//
|
|
426
429
|
|