From 98f4b7dfcb04d2f67ce93d31e6f4aed6bfe94199 Mon Sep 17 00:00:00 2001 From: Anthony Nahas Date: Mon, 23 Jul 2018 21:55:38 +0200 Subject: [PATCH] feat(package): added `linkify` pipe --- src/module/pipes/ngx-linkifyjs.pipe.spec.ts | 8 ++++++++ src/module/pipes/ngx-linkifyjs.pipe.ts | 14 ++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/module/pipes/ngx-linkifyjs.pipe.spec.ts create mode 100644 src/module/pipes/ngx-linkifyjs.pipe.ts diff --git a/src/module/pipes/ngx-linkifyjs.pipe.spec.ts b/src/module/pipes/ngx-linkifyjs.pipe.spec.ts new file mode 100644 index 00000000..07998393 --- /dev/null +++ b/src/module/pipes/ngx-linkifyjs.pipe.spec.ts @@ -0,0 +1,8 @@ +import { NgxLinkifyjsPipe } from './ngx-linkifyjs.pipe'; + +describe('NgxLinkifyjsPipe', () => { + it('create an instance', () => { + const pipe = new NgxLinkifyjsPipe(); + expect(pipe).toBeTruthy(); + }); +}); diff --git a/src/module/pipes/ngx-linkifyjs.pipe.ts b/src/module/pipes/ngx-linkifyjs.pipe.ts new file mode 100644 index 00000000..0c98da87 --- /dev/null +++ b/src/module/pipes/ngx-linkifyjs.pipe.ts @@ -0,0 +1,14 @@ +import {Pipe, PipeTransform} from '@angular/core'; +// @ts-ignore +import linkifyStr from 'linkifyjs/string'; + +@Pipe({ + name: 'linkify' +}) +export class NgxLinkifyjsPipe implements PipeTransform { + + transform(value: any, args?: any): string { + return value ? linkifyStr(value, {target: '_system'}) : value; + } + +}