Loading src/app/common/pipes/tags.spec.ts +9 −0 Original line number Original line Diff line number Diff line Loading @@ -58,6 +58,15 @@ describe('TagPipe', () => { ); ); }); }); it('should transform uppercase text following # to lower case ', () => { const pipe = new TagsPipe(featuresServiceMock); const string = 'textString #NaMe'; const transformedString = pipe.transform(<any>string); expect(transformedString).toContain( '<a href="/newsfeed/global/top;hashtag=name;period=24h' ); }); it('should correctly parse when duplicates substrings present', () => { it('should correctly parse when duplicates substrings present', () => { const pipe = new TagsPipe(featuresServiceMock); const pipe = new TagsPipe(featuresServiceMock); const string = '#hash #hashlonger'; const string = '#hash #hashlonger'; Loading src/app/common/pipes/tags.ts +5 −1 Original line number Original line Diff line number Diff line Loading @@ -32,7 +32,11 @@ export class TagsPipe implements PipeTransform { rule: /(^|\s||)#(\w+)/gim, rule: /(^|\s||)#(\w+)/gim, replace: m => { replace: m => { if (this.featureService.has('top-feeds')) { if (this.featureService.has('top-feeds')) { return `${m.match[1]}<a href="/newsfeed/global/top;hashtag=${m.match[2]};period=24h">#${m.match[2]}</a>`; return `${ m.match[1] }<a href="/newsfeed/global/top;hashtag=${m.match[2].toLowerCase()};period=24h">#${ m.match[2] }</a>`; } } return `${m.match[1]}<a href="/newsfeed/tag/${m.match[2]};ref=hashtag">#${m.match[2]}</a>`; return `${m.match[1]}<a href="/newsfeed/tag/${m.match[2]};ref=hashtag">#${m.match[2]}</a>`; }, }, Loading Loading
src/app/common/pipes/tags.spec.ts +9 −0 Original line number Original line Diff line number Diff line Loading @@ -58,6 +58,15 @@ describe('TagPipe', () => { ); ); }); }); it('should transform uppercase text following # to lower case ', () => { const pipe = new TagsPipe(featuresServiceMock); const string = 'textString #NaMe'; const transformedString = pipe.transform(<any>string); expect(transformedString).toContain( '<a href="/newsfeed/global/top;hashtag=name;period=24h' ); }); it('should correctly parse when duplicates substrings present', () => { it('should correctly parse when duplicates substrings present', () => { const pipe = new TagsPipe(featuresServiceMock); const pipe = new TagsPipe(featuresServiceMock); const string = '#hash #hashlonger'; const string = '#hash #hashlonger'; Loading
src/app/common/pipes/tags.ts +5 −1 Original line number Original line Diff line number Diff line Loading @@ -32,7 +32,11 @@ export class TagsPipe implements PipeTransform { rule: /(^|\s||)#(\w+)/gim, rule: /(^|\s||)#(\w+)/gim, replace: m => { replace: m => { if (this.featureService.has('top-feeds')) { if (this.featureService.has('top-feeds')) { return `${m.match[1]}<a href="/newsfeed/global/top;hashtag=${m.match[2]};period=24h">#${m.match[2]}</a>`; return `${ m.match[1] }<a href="/newsfeed/global/top;hashtag=${m.match[2].toLowerCase()};period=24h">#${ m.match[2] }</a>`; } } return `${m.match[1]}<a href="/newsfeed/tag/${m.match[2]};ref=hashtag">#${m.match[2]}</a>`; return `${m.match[1]}<a href="/newsfeed/tag/${m.match[2]};ref=hashtag">#${m.match[2]}</a>`; }, }, Loading