@angular/platform-browser#SafeResourceUrl TypeScript Examples

The following examples show how to use @angular/platform-browser#SafeResourceUrl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: safe.ts    From youpez-admin with MIT License 6 votes vote down vote up
/**
   * Transform
   *
   * @param value: string
   * @param type: string
   */
  transform(value: string, type: string): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl {
    switch (type) {
      case 'html':
        return this._sanitizer.bypassSecurityTrustHtml(value)
      case 'style':
        return this._sanitizer.bypassSecurityTrustStyle(value)
      case 'script':
        return this._sanitizer.bypassSecurityTrustScript(value)
      case 'url':
        return this._sanitizer.bypassSecurityTrustUrl(value)
      case 'resourceUrl':
        return this._sanitizer.bypassSecurityTrustResourceUrl(value)
      default:
        return this._sanitizer.bypassSecurityTrustHtml(value)
    }
  }
Example #2
Source File: SafePipe.ts    From geonetwork-ui with GNU General Public License v2.0 6 votes vote down vote up
public transform(
    value: any,
    type: string
  ): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl {
    switch (type) {
      case 'html':
        return this.sanitizer.bypassSecurityTrustHtml(value)
      case 'style':
        return this.sanitizer.bypassSecurityTrustStyle(value)
      case 'script':
        return this.sanitizer.bypassSecurityTrustScript(value)
      case 'url':
        return this.sanitizer.bypassSecurityTrustUrl(value)
      case 'resourceUrl':
        return this.sanitizer.bypassSecurityTrustResourceUrl(value)
      default:
        throw new Error(`Invalid safe type specified: ${type}`)
    }
  }
Example #3
Source File: app.component.ts    From geolocation with MIT License 6 votes vote down vote up
private getUrl(position: Position): SafeResourceUrl {
        const longitude = position.coords.longitude;
        const latitude = position.coords.latitude;

        return this.domSanitizer.bypassSecurityTrustResourceUrl(
            `//www.openstreetmap.org/export/embed.html?bbox=${longitude -
                0.005},${latitude - 0.005},${longitude + 0.005},${latitude +
                0.005}&marker=${position.coords.latitude},${
                position.coords.longitude
            }&layer=mapnik`,
        );
    }
Example #4
Source File: file-export.service.ts    From open-genes-frontend with Mozilla Public License 2.0 6 votes vote down vote up
public downloadJson(data): SafeResourceUrl {
    if (data?.length === 0) {
      return '';
    }

    const blob = new Blob([JSON.stringify(data)], {
      type: 'text/json;charset=utf-8',
    });
    return this.sanitizer.bypassSecurityTrustResourceUrl(URL.createObjectURL(blob));
  }
Example #5
Source File: file-export.service.ts    From open-genes-frontend with Mozilla Public License 2.0 6 votes vote down vote up
public downloadCsv(data): SafeResourceUrl {
    if (data?.length === 0) {
      return '';
    }

    const blob = new Blob([data], {
      type: 'text/csv;charset=utf-8',
    });

    return this.sanitizer.bypassSecurityTrustResourceUrl(URL.createObjectURL(blob));
  }
Example #6
Source File: safe.pipe.ts    From open-genes-frontend with Mozilla Public License 2.0 6 votes vote down vote up
public transform(
    value: any,
    type: string
  ): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl {
    switch (type) {
      case "html":
        return this.sanitizer.bypassSecurityTrustHtml(value);
      case "style":
        return this.sanitizer.bypassSecurityTrustStyle(value);
      case "styleUrl":
        // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
        return this.sanitizer.bypassSecurityTrustStyle(`url(${value})`);
      case "script":
        return this.sanitizer.bypassSecurityTrustScript(value);
      case "url":
        return this.sanitizer.bypassSecurityTrustUrl(value);
      case "resourceUrl":
        return this.sanitizer.bypassSecurityTrustResourceUrl(value);
      default:
        throw new Error(`Invalid safe type specified: ${type}`);
    }
  }
Example #7
Source File: ngx-gallery-thumbnails.component.ts    From ngx-gallery-9 with MIT License 6 votes vote down vote up
getImages(): string[] | SafeResourceUrl[] {
      if (!this.images) {
          return [];
      }

      if (this.remainingCount) {
          return this.images.slice(0, this.rows * this.columns);
      } 
      else if (this.lazyLoading && this.order != NgxGalleryOrder.Row) {
          let stopIndex = 0;

          if (this.order === NgxGalleryOrder.Column) {
              stopIndex = (this.index + this.columns + this.moveSize) * this.rows;
          }
          else if (this.order === NgxGalleryOrder.Page) {
              stopIndex = this.index + ((this.columns * this.rows) * 2);
          }

          if (stopIndex <= this.minStopIndex) {
              stopIndex = this.minStopIndex;
          } else {
              this.minStopIndex = stopIndex;
          }

          return this.images.slice(0, stopIndex);
      } 
      else {
          return this.images;
      }
  }
Example #8
Source File: safe.pipe.ts    From nica-os with MIT License 6 votes vote down vote up
public transform(value: any, type: string): SafeHtml | SafeStyle | SafeScript | SafeUrl | SafeResourceUrl {
    switch (type) {
      case 'html': return this.sanitizer.bypassSecurityTrustHtml(value);
      case 'style': return this.sanitizer.bypassSecurityTrustStyle(value);
      case 'script': return this.sanitizer.bypassSecurityTrustScript(value);
      case 'url': return this.sanitizer.bypassSecurityTrustUrl(value);
      case 'resourceUrl': return this.sanitizer.bypassSecurityTrustResourceUrl(value);
      default: throw new Error(`Invalid safe type specified: ${type}`);
    }
  }
Example #9
Source File: facet-preview.component.ts    From sba-angular with MIT License 5 votes vote down vote up
downloadUrl?: SafeResourceUrl;
Example #10
Source File: facet-preview.ts    From sba-angular with MIT License 5 votes vote down vote up
downloadUrl?: SafeResourceUrl;
Example #11
Source File: preview-panel.ts    From sba-angular with MIT License 5 votes vote down vote up
downloadUrl?: SafeResourceUrl;
Example #12
Source File: help.ts    From sba-angular with MIT License 5 votes vote down vote up
url: SafeResourceUrl;
Example #13
Source File: icon.module.ts    From fyle-mobile-app with MIT License 5 votes vote down vote up
private setPath(url: string): SafeResourceUrl {
    return this.domSanitizer.bypassSecurityTrustResourceUrl(url);
  }
Example #14
Source File: favourites-list.component.ts    From open-genes-frontend with Mozilla Public License 2.0 5 votes vote down vote up
public downloadLink: string | SafeResourceUrl = '#';
Example #15
Source File: download.component.ts    From open-genes-frontend with Mozilla Public License 2.0 5 votes vote down vote up
public currentDownloadLink: string | SafeResourceUrl = this.initialDownloadLinkVal;
Example #16
Source File: preview-document-iframe.component.ts    From sba-angular with MIT License 5 votes vote down vote up
// see https://stackoverflow.com/questions/45343810/how-to-access-the-nativeelement-of-a-component-in-angular4

    public sanitizedUrlSrc: SafeResourceUrl;
Example #17
Source File: app.component.ts    From ngx-videogular with MIT License 5 votes vote down vote up
currentDemo: SafeResourceUrl;
Example #18
Source File: safe_pipe.ts    From profiler with Apache License 2.0 5 votes vote down vote up
transform(url: any): SafeResourceUrl {
    return this.sanitizer.bypassSecurityTrustResourceUrl(url);
  }
Example #19
Source File: genes-list.component.ts    From open-genes-frontend with Mozilla Public License 2.0 5 votes vote down vote up
public downloadJsonLink: string | SafeResourceUrl = '#';
Example #20
Source File: search-view-panel.component.ts    From open-genes-frontend with Mozilla Public License 2.0 5 votes vote down vote up
@Input() downloadJsonLink: string | SafeResourceUrl = '#';
Example #21
Source File: app.component.ts    From geolocation with MIT License 5 votes vote down vote up
currentPositionUrl: SafeResourceUrl | null = null;
Example #22
Source File: app.component.ts    From aws-power-tuner-ui with Apache License 2.0 5 votes vote down vote up
visualisationUrl: SafeResourceUrl;
Example #23
Source File: app.component.ts    From ngx-videogular with MIT License 5 votes vote down vote up
currentDemo: SafeResourceUrl;
Example #24
Source File: ngx-gallery.component.ts    From ngx-gallery-9 with MIT License 5 votes vote down vote up
bigImages: string[] | SafeResourceUrl[];
Example #25
Source File: safe-url.pipe.ts    From mylog14 with GNU General Public License v3.0 5 votes vote down vote up
transform(url: string): SafeResourceUrl {
    return this.sanitizer.bypassSecurityTrustResourceUrl(url);
  }
Example #26
Source File: blog-post-details.ts    From ionic-doctor-online with MIT License 5 votes vote down vote up
trustedVideoUrl: SafeResourceUrl;
Example #27
Source File: ngx-gallery-image.model.ts    From ngx-gallery-9 with MIT License 5 votes vote down vote up
small?: string | SafeResourceUrl;
Example #28
Source File: ngx-gallery-image.model.ts    From ngx-gallery-9 with MIT License 5 votes vote down vote up
medium?: string | SafeResourceUrl;
Example #29
Source File: ngx-gallery-image.model.ts    From ngx-gallery-9 with MIT License 5 votes vote down vote up
big?: string | SafeResourceUrl;