@chat21/chat21-web-widget 5.1.0-rc14 → 5.1.0-rc16

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,10 @@
6
6
  ### **Copyrigth**:
7
7
  *Tiledesk SRL*
8
8
 
9
+ # 5.1.0-rc16
10
+ - **added**: hideOnSpecificUrlList replaced in favour of hideOnSpecificDomainList
11
+
12
+ # 5.1.0-rc15
9
13
  # 5.1.0-rc14
10
14
  - **added**: ability to hide widget on selected domains based on hideOnSpecificDomainList variable
11
15
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chat21/chat21-web-widget",
3
3
  "author": "Tiledesk SRL",
4
- "version": "5.1.0-rc14",
4
+ "version": "5.1.0-rc16",
5
5
  "license": "MIT",
6
6
  "homepage": "https://www.tiledesk.com",
7
7
  "repository": {
@@ -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
- this.logger.error('[Check canLoad] Widget is not able to load on this domain!!!')
268
+ console.error('[Check canLoad] Widget is not able to load on this domain!!!')
269
269
  this.hideWidget()
270
270
  this.disposeWidget();
271
271
  }
@@ -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('hideOnSpecificDomainList')) {
520
- globals['hideOnSpecificDomainList'] = variables['hideOnSpecificDomainList'];
519
+ if (variables.hasOwnProperty('hideOnSpecificUrl')) {
520
+ globals['hideOnSpecificUrl'] = variables['hideOnSpecificUrl'];
521
+ }
522
+ if (variables.hasOwnProperty('hideOnSpecificUrlList')) {
523
+ globals['hideOnSpecificUrlList'] = variables['hideOnSpecificUrlList'];
521
524
  }
522
525
 
523
526
  }
@@ -1974,11 +1977,28 @@ export class GlobalSettingsService {
1974
1977
  }
1975
1978
 
1976
1979
  manageLoadingDomains(): boolean {
1977
- if(!this.globals.hideOnSpecificDomainList){
1980
+
1981
+ if(!this.globals.hideOnSpecificUrlList || !this.globals.hideOnSpecificUrl){
1982
+ console.log('No hideOnSpecificUrlList or hideOnSpecificUrl');
1978
1983
  return true
1979
1984
  }
1980
- let isAllowedToLoad = !isAllowedUrlInText(this.globals.windowContext.location.origin, [])
1981
- return isAllowedToLoad
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 shouldHide = this.globals.hideOnSpecificUrlList.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 !shouldHide
1982
2002
  }
1983
2003
 
1984
2004
  }
@@ -219,7 +219,8 @@ export class Globals {
219
219
  showAttachmentFooterButton: boolean // ******* new ********
220
220
  showAudioRecorderFooterButton: boolean // ******* new ********
221
221
 
222
- hideOnSpecificDomainList: Array<string> // ******* new ********
222
+ hideOnSpecificUrl: boolean // ******* new ********
223
+ hideOnSpecificUrlList: 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;
423
+ /** enabled to set a list of domain not able to load the widget **/
424
+ this.hideOnSpecificUrl = false
422
425
  /** set a list of domain not able to load the widget */
423
- this.hideOnSpecificDomainList = [];
426
+ this.hideOnSpecificUrlList = [];
424
427
 
425
428
  // ============ END: SET EXTERNAL PARAMETERS ==============//
426
429