fix: add rules for video conversion#703
Conversation
Signed-off-by: dominictb <tb-dominic@outlook.com>
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
|
recheck |
Signed-off-by: dominictb <tb-dominic@outlook.com>
|
@DylanDylann for whatever reason, I can't add you as a reviewer, but think you should review this one since it ties closely with Expensify/App#42463. |
Signed-off-by: dominictb <tb-dominic@outlook.com>
|
@dominictb Also please help to format code by the "npm run prettier" command |
Signed-off-by: dominictb <tb-dominic@outlook.com>
Signed-off-by: dominictb <tb-dominic@outlook.com>
DylanDylann
left a comment
There was a problem hiding this comment.
Some minor comments. Everything else is fine. Thanks for your work
| */ | ||
| { | ||
| name: 'image', | ||
| name: 'imageOrVideo', |
There was a problem hiding this comment.
NAB: We might consider breaking this down into two separate rules: image and video. By doing this, we could differentiate between videos and images using the specified REGEX.
Anyway, the current code also looks good to me
There was a problem hiding this comment.
I agree that this should be split into two different rules if that's easily doable.
| } | ||
| return `<img src="${Str.sanitizeURL(g2)}"${g1 ? ` alt="${this.escapeAttributeContent(g1)}"` : ''} />`; | ||
| }, | ||
| // will need to update this similarly |
There was a problem hiding this comment.
I think we can remove this comment 😄
| return `!(${g2})`; | ||
| }, | ||
| }, | ||
|
|
Reviewer Checklist
Screenshots/VideosMacOS: Chrome / SafariScreen.Recording.2024-06-13.at.19.05.38.mov |
|
@tgolen Ping you here because Melvin isn't assigned |
| */ | ||
| { | ||
| name: 'image', | ||
| name: 'imageOrVideo', |
There was a problem hiding this comment.
I agree that this should be split into two different rules if that's easily doable.
Signed-off-by: dominictb <tb-dominic@outlook.com>
|
@tgolen @DylanDylann please help re-review! |
Co-authored-by: DylanDylann <141406735+DylanDylann@users.noreply.github.com>
Signed-off-by: dominictb <tb-dominic@outlook.com>
Signed-off-by: dominictb <tb-dominic@outlook.com>
|
@tgolen All yours 🚀 |
| regex: MARKDOWN_VIDEO_REGEX, | ||
| /** | ||
| * @param {string} match | ||
| * @param {string} g1 - The first capture group - video name |
There was a problem hiding this comment.
Please rename these to group1 and group2. We should never have allowed other authors to get away with it in the other functions because it's against our style guide. Bonus points if you update the other method params so everything is consistent!
There was a problem hiding this comment.
I've changed the variable name: instead of g1, g2 now we have videoSource, videoName,...
| regex: /<video[^><]*data-expensify-source\s*=\s*(['"])(\S*?)\1(.*?)>([^><]*)<\/video>*(?![^<][\s\S]*?(<\/pre>|<\/code>))/gi, | ||
| /** | ||
| * @param {string} match The full match | ||
| * @param {string} g1 {string} The first capture group |
There was a problem hiding this comment.
I like the comments, thank you! Something else I think we should consider is using named capture groups. I think that would really help clarify the variables.
Signed-off-by: dominictb <tb-dominic@outlook.com>
tgolen
left a comment
There was a problem hiding this comment.
Ah, I love the named parameters. Thank you!
|
🚀Published to npm in v2.0.16 |
Fixed Issues
$ Expensify/App#41952
Tests
Unit tests added in the PR
QA