Ontica/Empiria.Land.Intranet

View on GitHub
src/app/shared/pipes/safe-url.pipe.ts

Summary

Maintainability
A
0 mins
Test Coverage

/**
 * @license
 * Copyright (c) La Vía Óntica SC, Ontica LLC and contributors. All rights reserved.
 *
 * See LICENSE.txt in the project root for complete license information.
 */

import { Pipe, PipeTransform } from '@angular/core';

import { DomSanitizer } from '@angular/platform-browser';


@Pipe({
  name: 'safeUrl'
})
export class SafeUrlPipe implements PipeTransform {

  constructor(private sanitized: DomSanitizer) { }

  transform(value) {
    if (value) {
      return this.sanitized.bypassSecurityTrustResourceUrl(value);
    } else {
      return '';
    }
  }

}