All files / src/app/core/pipes sanitize.pipe.ts

100% Statements 4/4
100% Branches 2/2
100% Functions 1/1
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 153x     3x   10x                  
import { Pipe, PipeTransform } from '@angular/core';
 
@Pipe({ name: 'ishSanitize', pure: true })
export class SanitizePipe implements PipeTransform {
  transform(value: string): string {
    return value !== undefined
      ? value
          .replace(/[^a-zA-Z0-9-]/g, '_')
          .replace(/_+/g, '_')
          .replace(/^_+/g, '')
          .replace(/_+$/g, '')
      : 'undefined';
  }
}