-
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: no trimming for link name #773
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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
Oops, something went wrong.
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.
@dominictb Could you explain why we need to change this regex?
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.
expensify-common/__tests__/ExpensiMark-HTML-test.js
Line 2271 in 4f2e0bc
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.
@dominictb In this case, shouldKeepRawInput is false, right?
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.
So I don't think this test relate to our change
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.
If we keep the old regex, then in markdown input we'll see:
Based on what I saw in the unit test here, the report mention markdown syntax should not be applied if it is inside a link. So this is not expected right?
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'm under the assumption that before this change, the
#room
text shouldn't have the report-mention markdown if it is inside a link markdown syntax (see the image above)However, after my change, the
#room
text will now have the report-mention markdown style (check the image below), but I believe this only happens in the markdown input, not when we save/send the message as we have already trim the extra space at that point, hence the#room
text won't have the report-mention markdown style. So, the question is: is this acceptable to show the report-mention markdown style in the markdown input in this case or not? It might be confusing for the user because what they saw when typing and when viewing the sent message is 2 different thing.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.
@dominictb Yeah, agree that the report-mention markdown style shouldn't be rendered. But my curious why we have different behaviors when trimming spaces. Could you refer to a code link for this point?
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.
that is because we're trying to match and apply report-mention rule to the link name, and since the original regex of the report-mention doesn't account for the case where link name can have spaces on both end -> hence the mentioned problem
The solution is to update the regex, making sure that if the
mention-report
is between<a/>
tag, we won't render the markdown style. We have the same logic to prevent applyingmention-report
markdown style inpre
andcode
block, so it should be straightforwardWe only keep the space in when
shouldKeepRawInput = true
, and this particular problem only happens when the link name have redundant spaces on either end. So, it only happens in the markdown input (shouldKeepRawInput = true
), but not when we display the sent message in the app (``shouldKeepRawInput = false`)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.
Yeah, I understand your problem and solution. But the RCA isn't clear to me
For this question, I am curious why the old mention-report regex works well when we trim spaces but It fails when we keep trailing spaces
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.
Ahhh, see. It dues to the negative lookbehind. Sorry for my confusion