Commit dd210419 authored by Ben's avatar Ben
Browse files

Force tags to lowercase in discovery

parent 9483040f
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -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';
+5 −1
Original line number Original line Diff line number Diff line
@@ -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>`;
      },
      },