App icon indicating copy to clipboard operation
App copied to clipboard

[HOLD for payment 2022-09-26] [$2000] Some links are not formatted as markdown links

Open mvtglobally opened this issue 4 years ago • 75 comments

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:

  1. Navigate to app
  2. Send a message with a link such as https://mail.google.com
  3. 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

View all open jobs on GitHub

mvtglobally avatar Jul 01 '22 05:07 mvtglobally

Triggered auto assignment to @TomatoToaster (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

melvin-bot[bot] avatar Jul 01 '22 05:07 melvin-bot[bot]

I think this will make a great external issue.

TomatoToaster avatar Jul 01 '22 15:07 TomatoToaster

Triggered auto assignment to @mallenexpensify (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

melvin-bot[bot] avatar Jul 01 '22 15:07 melvin-bot[bot]

@mallenexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

melvin-bot[bot] avatar Jul 04 '22 19:07 melvin-bot[bot]

Triggered auto assignment to @JmillsExpensify (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

melvin-bot[bot] avatar Jul 05 '22 18:07 melvin-bot[bot]

Seems like a regression from this PR https://github.com/Expensify/App/pull/9405

mdneyazahmad avatar Jul 06 '22 11:07 mdneyazahmad

Looks like we're outside of the regression period hold. I'll go ahead and create a new Upwork issue.

JmillsExpensify avatar Jul 06 '22 22:07 JmillsExpensify

Triggered auto assignment to Contributor-plus team member for initial proposal review - @Santhosh-Sellavel (Exported)

melvin-bot[bot] avatar Jul 06 '22 22:07 melvin-bot[bot]

Triggered auto assignment to @luacmartins (Exported), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

melvin-bot[bot] avatar Jul 06 '22 22:07 melvin-bot[bot]

@allroundexperts since you worked on the last PR.

luacmartins avatar Jul 07 '22 00:07 luacmartins

@JmillsExpensify We are still on regression period only. The PR is not yet deployed on production

cc: @luacmartins

Santhosh-Sellavel avatar Jul 07 '22 15:07 Santhosh-Sellavel

Oh great! Closing out the Upwork job in that case.

JmillsExpensify avatar Jul 07 '22 18:07 JmillsExpensify

Commented in the original issue/PR regarding this regression.

JmillsExpensify avatar Jul 12 '22 16:07 JmillsExpensify

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

mananjadhav avatar Jul 12 '22 18:07 mananjadhav

@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 avatar Jul 12 '22 21:07 luacmartins

@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.

mananjadhav avatar Jul 13 '22 17:07 mananjadhav

This issue is not a regression, but a new bug we discovered by removing the autolink when editing a message - see this comment.

luacmartins avatar Jul 13 '22 17:07 luacmartins

Updated issue title and reproduction steps! Thanks @mananjadhav for clarifying this!

luacmartins avatar Jul 13 '22 17:07 luacmartins

Open to proposals here!

Santhosh-Sellavel avatar Jul 13 '22 18:07 Santhosh-Sellavel

Proposal

  1. When a user does not enter protocol it will be https by 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}`
                ),
  1. 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:

  1. google.com - (text: google.com, url: https://google.com)
  2. [Google](google.com) - (text: Google, url: https://google.com)
  3. [https://google.com](google.com) - (text: https://google.com, url: https://google.com)
  4. 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:

Screenshot 2022-07-15 at 12 21 13 PM

mdneyazahmad avatar Jul 15 '22 06:07 mdneyazahmad