Skip to content
Snippets Groups Projects
Commit 08895301 authored by Ben's avatar Ben
Browse files

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
parents 9adda44a cee746c8
No related branches found
No related tags found
Loading
...@@ -79,6 +79,14 @@ describe('TagPipe', () => { ...@@ -79,6 +79,14 @@ describe('TagPipe', () => {
expect(transformedString).toContain('<a class="tag"'); 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', () => { it('should transform to an email', () => {
const pipe = new TagsPipe(featuresServiceMock); const pipe = new TagsPipe(featuresServiceMock);
const string = 'textstring@name.com'; const string = 'textstring@name.com';
...@@ -90,7 +98,6 @@ describe('TagPipe', () => { ...@@ -90,7 +98,6 @@ describe('TagPipe', () => {
const pipe = new TagsPipe(featuresServiceMock); const pipe = new TagsPipe(featuresServiceMock);
const string = 'textstring name'; const string = 'textstring name';
const transformedString = pipe.transform(<any>string); const transformedString = pipe.transform(<any>string);
expect(transformedString).toEqual(string); expect(transformedString).toEqual(string);
expect(transformedString).not.toContain('<a class="tag"'); expect(transformedString).not.toContain('<a class="tag"');
}); });
......
...@@ -39,9 +39,9 @@ export class TagsPipe implements PipeTransform { ...@@ -39,9 +39,9 @@ export class TagsPipe implements PipeTransform {
} }
}, },
at: { at: {
rule: /(^|\s|\W)@(\w*[a-zA-Z_-]+\w*)/gim, rule: /(^|\W)@([a-z0-9_\-\.]+[a-z0-9_])(\W|$)/gmi,
replace: (m) => { 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]}`;
} }
} }
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment