-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: move autoEmail to before mentions #550
Merged
cead22
merged 10 commits into
Expensify:main
from
tienifr:fix/move-autoEmail-to-before-mentions
Jul 12, 2023
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a176ef2
fix: move autoEmail to before mentions
tienifr 5269ba3
add unit test
tienifr a8bb209
revert previous change ; modify mention regex to include valid email …
tienifr 05d9a30
add underscore in beginning of MARKDOWN_EMAIL regex
tienifr 383b746
revert old test, revert _ in MARKDOWN_EMAIL since it contradict with …
tienifr b8bbcde
fix lint
tienifr 1d17063
fix mention and email edge cases
tienifr cc11e21
fix lint
tienifr 832b1d8
remove redundant '#' character from isValidMention
tienifr 3961539
modify comment
tienifr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1048,3 +1048,63 @@ test('Skip rendering invalid markdown',() => { | |
testString = '> *This is multiline\nbold text*'; | ||
expect(parser.replace(testString)).toBe('<blockquote>*This is multiline</blockquote>bold text*'); | ||
}); | ||
|
||
test('Test for email with [email protected]@gmail.com', () => { | ||
const testString = '[email protected]@gmail.com'; | ||
const resultString = '<a href=\"mailto:[email protected]\">[email protected]</a>@gmail.com'; | ||
expect(parser.replace(testString)).toBe(resultString); | ||
}); | ||
|
||
test('Test for email with [email protected]@gmail.com', () => { | ||
const testString = '[email protected]@gmail.com'; | ||
const resultString = '<a href=\"mailto:[email protected]\">[email protected]</a>@gmail.com'; | ||
expect(parser.replace(testString)).toBe(resultString); | ||
}); | ||
|
||
test('Test for email with test@[email protected]', () => { | ||
const testString = 'test@[email protected]'; | ||
const resultString = 'test@<a href=\"mailto:[email protected]\">[email protected]</a>'; | ||
expect(parser.replace(testString)).toBe(resultString); | ||
}); | ||
|
||
test('Test for email with test+1@[email protected]', () => { | ||
const testString = 'test+1@[email protected]'; | ||
const resultString = 'test+1@<a href=\"mailto:[email protected]\">[email protected]</a>'; | ||
expect(parser.replace(testString)).toBe(resultString); | ||
}); | ||
|
||
test('Test user mention with @[email protected]', () => { | ||
const testString = '@[email protected]'; | ||
const resultString = '<mention-user>@[email protected]</mention-user>'; | ||
expect(parser.replace(testString)).toBe(resultString); | ||
}); | ||
|
||
test('Test user mention with @[email protected]', () => { | ||
const testString = '@[email protected]'; | ||
const resultString = '<mention-user>@[email protected]</mention-user>'; | ||
expect(parser.replace(testString)).toBe(resultString); | ||
}); | ||
|
||
test('Test user mention with @[email protected]', () => { | ||
const testString = '@[email protected]'; | ||
const resultString = '<mention-user>@[email protected]</mention-user>'; | ||
expect(parser.replace(testString)).toBe(resultString); | ||
}); | ||
|
||
test('Test here mention with @here_@here_.com', () => { | ||
const testString = '@here_@here_.com'; | ||
const resultString = '<mention-here>@here</mention-here><em><mention-here>@here</mention-here></em>.com'; | ||
expect(parser.replace(testString)).toBe(resultString); | ||
}); | ||
|
||
test('Test here mention with @here@', () => { | ||
const testString = '@here@'; | ||
const resultString = '<mention-here>@here</mention-here>@'; | ||
expect(parser.replace(testString)).toBe(resultString); | ||
}); | ||
|
||
test('Test here mention with @here@here', () => { | ||
const testString = '@here@here'; | ||
const resultString = '<mention-here>@here</mention-here><mention-here>@here</mention-here>'; | ||
expect(parser.replace(testString)).toBe(resultString); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,7 +77,6 @@ describe('Str.isValidMention', () => { | |
expect(Str.isValidMention('*@[email protected]*')).toBeTruthy(); | ||
expect(Str.isValidMention(' @[email protected]')).toBeTruthy(); | ||
expect(Str.isValidMention('~@[email protected]~')).toBeTruthy(); | ||
expect(Str.isValidMention('#@[email protected]')).toBeTruthy(); | ||
expect(Str.isValidMention('_@[email protected]_')).toBeTruthy(); | ||
expect(Str.isValidMention('`@[email protected]`')).toBeFalsy(); | ||
expect(Str.isValidMention('\'@[email protected]\'')).toBeTruthy(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
#
supposed to be here? I thought#
was used for headings like so# heading 1
, ie, with a#
before the text but without a#
after the textThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct?
I think I'm missing something, can mention start and end with *, _, #, ', or "?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eVoloshchak it can "start" with
*
in the sense that the mention can be within two*
, so it'll still technically start with an@
, but this is saying it can start with*
becasue it can be likelet's ask *@[email protected]*
.This is why I asked about
#
, cause that one is only a leading character unlike*
,_
,'
,"
, and~
.Incidentally @tienifr, the
~
is missing from the commentstarts and ends with a *, _, #, ', or "...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed that. Thanks for pointing it out.
I agree that
#
is redundant here since it is only a leading character, and we can get rid of it. It also does not affect the current behavior of either this PR or the current staging version