Commit 08895301 authored by Ben Hayward's avatar Ben Hayward

Merge branch 'period-char-username-cutoff-tag-fix' of...

Merge branch 'period-char-username-cutoff-tag-fix' of gitlab.com:benhayward.ben/front into fix/period-char-username-cutoff-tag-89
1 merge request!401[Sprint/HipsterHedgehog](bug) Updated tags pipe to allow . character mid tag #89
Pipeline #68892581 running with stages
......@@ -79,6 +79,14 @@ describe('TagPipe', () => {
expect(transformedString).toContain('<a class="tag"');
});
it('should transform when @ followed by `.com`', () => {
const pipe = new TagsPipe(featuresServiceMock);
const string = 'textstring @name.com';
const transformedString = pipe.transform(<any>string);
expect(transformedString).toContain('<a class="tag"');
expect(transformedString).toContain('@name.com');
});
it('should transform to an email', () => {
const pipe = new TagsPipe(featuresServiceMock);
const string = 'textstring@name.com';
......@@ -90,7 +98,6 @@ describe('TagPipe', () => {
const pipe = new TagsPipe(featuresServiceMock);
const string = 'textstring name';
const transformedString = pipe.transform(<any>string);
expect(transformedString).toEqual(string);
expect(transformedString).not.toContain('<a class="tag"');
});
......
......@@ -39,9 +39,9 @@ export class TagsPipe implements PipeTransform {
}
},
at: {
rule: /(^|\s|\W)@(\w*[a-zA-Z_-]+\w*)/gim,
rule: /(^|\W)@([a-z0-9_\-\.]+[a-z0-9_])(\W|$)/gmi,
replace: (m) => {
return `${m.match[1]}<a class="tag" href="/${m.match[2]}" target="_blank">@${m.match[2]}</a>`;
return `${m.match[1]}<a class="tag" href="/${m.match[2]}" target="_blank">@${m.match[2]}</a>${m.match[3]}`;
}
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment