[HOLD for payment 2022-09-26] [$2000] Some links are not formatted as markdown links
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Action Performed:
- Navigate to app
- Send a message with a link such as
https://mail.google.com - Tap edit and verify that the link does not have markdown syntax around it
Expected Result:
Link should have markdown syntax
Actual Result:
Link does not have markdown syntax
Workaround:
Manually add markdown
Platform:
Where is this issue occurring?
- Web
- iOS
- Android
- Desktop App
- Mobile Web
Version Number: 1.1.79-2 Reproducible in staging?: Y Reproducible in production?: Y Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Notes/Photos/Videos: Any additional supporting documentation
https://user-images.githubusercontent.com/43995119/176832053-ac88936a-9b90-4893-ab43-be606abdebd7.mov
Expensify/Expensify Issue URL: Issue reported by: @NikkiWines Slack conversation: https://expensify.slack.com/archives/C01GTK53T8Q/p1656458072949539
Triggered auto assignment to @TomatoToaster (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.
I think this will make a great external issue.
Triggered auto assignment to @mallenexpensify (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.
@mallenexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
Triggered auto assignment to @JmillsExpensify (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.
Seems like a regression from this PR https://github.com/Expensify/App/pull/9405
Looks like we're outside of the regression period hold. I'll go ahead and create a new Upwork issue.
Triggered auto assignment to Contributor-plus team member for initial proposal review - @Santhosh-Sellavel (Exported)
Triggered auto assignment to @luacmartins (Exported), see https://stackoverflow.com/c/expensify/questions/7972 for more details.
@allroundexperts since you worked on the last PR.
@JmillsExpensify We are still on regression period only. The PR is not yet deployed on production
cc: @luacmartins
Oh great! Closing out the Upwork job in that case.
Commented in the original issue/PR regarding this regression.
Are we saying we allow autolink for create message but not for edit message?
@luacmartins I am not sure how we would call it a regression. I explicitly asked the same test case in this https://github.com/Expensify/App/issues/9090#issuecomment-1145298738. The PR does the same effect, that the autoLink works when inserting but doesn't when editing.
We could tag this as a new issue - If the user is posting link with the protocol, then it should be transformed into the markdown format or revert the PR and rethink on how we would want to achieve the remove link feature.
https://user-images.githubusercontent.com/3069065/178571896-3570f289-4f90-4b92-84b8-d051fca67dc9.mov
@luacmartins I am not sure how we would call it a regression. I explicitly asked the same test case in this https://github.com/Expensify/App/issues/9090#issuecomment-1145298738. The PR does the same effect, that the autoLink works when inserting but doesn't when editing.
Maybe I misunderstood your question, but the expected behavior is described in the issue and was clarified here. If the user intentionally removed the link markdown from [example](link.com) to link.com while editing, we shouldn't make it [example](link.com) again and re-add the hyperlink. If the user edits a message but doesn't change the link markdown, we should do nothing and let the hyperlink as is. This is a regression because we are removing the hyperlink even when the user doesn't edit the hyperlink markdown in the message.
@luacmartins We should update the title of the issue to Some links are not formatted as markdown links or something similar https://github.com/Expensify/App/issues/9090#issuecomment-1183459903 and refine the GH body here.
This issue is not a regression, but a new bug we discovered by removing the autolink when editing a message - see this comment.
Updated issue title and reproduction steps! Thanks @mananjadhav for clarifying this!
Open to proposals here!
Proposal
- When a user does not enter protocol it will be
httpsby default.
https://github.com/Expensify/expensify-common/blob/46b8533e44dbf9d0c20263687d34c6cdb51e0682/lib/ExpensiMark.js#L121-L123
replacement: (match, g1, g2, g3) => (
`${g1}<a href="${g3 && g3.includes('http') ? '' : 'https://'}${g2}" target="_blank" rel="noreferrer noopener">${g2}</a>${g1}`
),
- When text and url are different HTML to markdown will use
[text](url)or else just url
https://github.com/Expensify/expensify-common/blob/46b8533e44dbf9d0c20263687d34c6cdb51e0682/lib/ExpensiMark.js#L259-L269
{
name: 'anchor',
regex: /<(a)[^><]*href\s*=\s*(['"])(.*?)\2(?:".*?"|'.*?'|[^'"><])*>(.*?)<\/\1>(?![^<]*(<\/pre>|<\/code>))/gi,
replacement: (match, g1, g2, g3, g4) => {
const link = g3.startsWith('mailto:') ? g3.slice(7) : g3;
if (link !== g4) {
return `[${g4}](${link})`;
}
return link;
},
},
Example:
google.com - (text: google.com, url: https://google.com)[Google](google.com) - (text: Google, url: https://google.com)[https://google.com](google.com) - (text: https://google.com, url: https://google.com)https://google.com - (text: https://google.com, url: https://google.com)
You can conclude from point 1 and 2, example 3, 4 does not display markdown syntax links.
If we do always want to show links
{
name: 'anchor',
regex: /<(a)[^><]*href\s*=\s*(['"])(.*?)\2(?:".*?"|'.*?'|[^'"><])*>(.*?)<\/\1>(?![^<]*(<\/pre>|<\/code>))/gi,
replacement: (match, g1, g2, g3, g4) => {
const link = g3.startsWith('mailto:') ? g3.slice(7) : g3;
- if (link !== g4) {
return `[${g4}](${link})`;
- }
- return link;
},
},
Result: