-
Notifications
You must be signed in to change notification settings - Fork 132
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: export link regex for use in edit message #540
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
recheck |
@MariaHCD |
@neil-marcellini and I will be reviewing this. |
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.
@s-alves10 your current change itself looks good.
But how will you solve this regression - Expensify/App#18911 (comment)?
@aimane-chnaif result18911.mp4 |
lib/ExpensiMark.js
Outdated
@@ -3,6 +3,8 @@ import Str from './str'; | |||
import {MARKDOWN_URL_REGEX, LOOSE_URL_REGEX, URL_REGEX} from './Url'; | |||
import {CONST} from './CONST'; | |||
|
|||
const MARKDOWN_LINK_REGEX = `\\[([^\\][]*(?:\\[[^\\][]*][^\\][]*)*)]\\(${MARKDOWN_URL_REGEX}\\)(?![^<]*(<\\/pre>|<\\/code>))`; |
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.
Move this to Url.js
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.
@aimane-chnaif
I intentionally placed this constant in ExpensiMark.js. This is not the URL regex, is the regex for parsing markdown URL.
Should I still move this regex to Url.js?
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.
Still I suggest Url.js.
There's no non-default exported const or function defined in ExpensiMark.js
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.
@aimane-chnaif
Moved
can you explain why escape should work? |
@aimane-chnaif |
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.
LGTM!
cc: @neil-marcellini @MariaHCD
@neil-marcellini @MariaHCD Will you review this PR? |
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.
Sorry to keep changing my recommendations, I want to make sure this works as well as possible and stays consistent in the future.
How about we just move these two functions from App to expensify-common, then we can simply use them in App?
lib/Url.js
Outdated
@@ -16,6 +16,7 @@ const LOOSE_URL_REGEX = `((${LOOSE_URL_WEBSITE_REGEX})${URL_PATH_REGEX}(?:${URL_ | |||
|
|||
|
|||
const MARKDOWN_URL_REGEX = `(${LOOSE_URL_REGEX}|${URL_REGEX})`; | |||
const MARKDOWN_LINK_REGEX = `\\[([^\\][]*(?:\\[[^\\][]*][^\\][]*)*)]\\(${MARKDOWN_URL_REGEX}\\)(?![^<]*(<\\/pre>|<\\/code>))`; |
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.
This doesn't seem relevant here because it is about links, not just URLs.
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.
Moved to ExpensiMark.js
lib/ExpensiMark.js
Outdated
`\\[([^\\][]*(?:\\[[^\\][]*][^\\][]*)*)]\\(${MARKDOWN_URL_REGEX}\\)(?![^<]*(<\\/pre>|<\\/code>))`, | ||
'gi', | ||
); | ||
const regex = new RegExp(MARKDOWN_LINK_REGEX, 'gi'); |
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.
Here's we're building a regex with the 'gi'
flags, but in App we're using the 'gm'
flags. That's an example of an inconsistency with this approach.
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.
@neil-marcellini
I think gi
flag is intentional not to parse multiline link. In App, we'll be using gi
flags as well.
Actually, ExpensiMark
uses this flag for both link
and autolink
at the moment.
@neil-marcellini ok, I don't mind about that refactoring. But how about the main solution? |
@neil-marcellini |
Looks like @neil-marcellini has got this covered, un-assigning myself as reviewer. |
@neil-marcellini |
@s-alves10 I will look at this within the next hour. Please feel free to message me on NewDot if you want to chat quickly. |
Please let me know your address on NewDot |
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.
We started a group DM in NewDot to discuss.
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.
Looking pretty good!
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.
Nice, good to go!
@@ -3,7 +3,7 @@ import Str from './str'; | |||
import {MARKDOWN_URL_REGEX, LOOSE_URL_REGEX, URL_REGEX} from './Url'; | |||
import {CONST} from './CONST'; | |||
|
|||
const MARKDOWN_LINK_REGEX = `\\[([^\\][]*(?:\\[[^\\][]*][^\\][]*)*)]\\(${MARKDOWN_URL_REGEX}\\)(?![^<]*(<\\/pre>|<\\/code>))`; | |||
const MARKDOWN_LINK_REGEX = new RegExp(`\\[([^\\][]*(?:\\[[^\\][]*][^\\][]*)*)]\\(${MARKDOWN_URL_REGEX}\\)(?![^<]*(<\\/pre>|<\\/code>))`, 'gi'); |
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.
NAB: Add a 'P' to the end of the name so we know it's not just a string MARKDOWN_LINK_REGEXP
. Idk, maybe too subtle.
Fixed Issues
$ Expensify/App#18911
Tests
ExpensiMark-HTML-test.js. Nothing added because there is no regex change.
Make sure that all unit-tests are passed.
QA
This PR has no regex change. Can verify if all unit-tests are passed.
Nothing.