Page MenuHomePhabricator

[Cashtab] Parse links in Cashtab Messages
AbandonedPublic

Authored by bytesofman on Dec 22 2022, 20:26.

Details

Reviewers
kieran709
Group Reviewers
Restricted Project
Summary

Related to T2866. Added logic and styling to parse and render URLs in cashtab messages and return them as clickable links. This could be taken care of more cleanly with a library but I wanted to attempt it without a library before going that route.

Test Plan

cd web/cashtab && npm start
if there are no cashtab messages in recent tx history that contain links, receive some in the active wallet
observe that the URLs in the messages are now clickable links

Diff Detail

Repository
rABC Bitcoin ABC
Branch
parse-links-opReturn-msgs
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 21668
Build 42976: Build Diffcashtab-tests
Build 42975: arc lint + arc unit

Event Timeline

bytesofman requested changes to this revision.Jan 3 2023, 18:25

Great diff. A couple of mods:

  1. This eats a space after the URL for messages that include a URL with text afterward
  2. This won't parse URLs without https://, ideally we don't want to make users add extra characters into OP_RETURN, e.g. cashtab.com should be parsed

image.png (471×502 px, 43 KB)

This revision now requires changes to proceed.Jan 3 2023, 18:25

Having looked into it I am not certain I can parse relative links without a protocol unless at the very least, an external library is added. That said even the external libraries I have tested aren't perfect( lists of links separated by commas (ex. google.com, cashtab.com, yahoo.com becomes google.com, cashtab.com, yahoo.com,), if a url is provided that does not support https it cannot really be accounted for, plus some other nits). Let me know if you want to see a version that uses an external library, or if you have any advice for how to improve the functionality here I would appreciate it.

web/cashtab/src/components/Home/Tx.js
475

mb this for supporting shorthand URLs, e.g. "cashtab.com"

return Boolean(new URL(urlString) || new URL(`https://${urlString}`)
bytesofman abandoned this revision.
bytesofman edited reviewers, added: kieran709; removed: bytesofman.

May implement this later. Diff is a good proof of concept. Not high priority with current resourcing.