lbryio / lbry-desktop

A browser and wallet for LBRY, the decentralized, user-controlled content marketplace.
https://lbry.tech
MIT License
3.56k stars 414 forks source link

Markdown preview breaks when using a lbry link in angle brackets #4797

Closed JonFStr closed 4 years ago

JonFStr commented 4 years ago

Bug The Markdown preview in the post editor fails to load, if you use a lbry://-link in angle brackets

To Reproduce

  1. Go to the upload page and select "Post"
  2. Enter a link with angle brackets, e.g. <lbry://@lbry#3f/googlebanslbry#7>
  3. Click the preview icon
  4. The preview display fails; in the developer tools the following error is shown:
    Uncaught Error: Invariant failed
    at t.a (tiny-invariant.esm.js:8)
    at Object.children (react-router-dom.js:181)
    at e.t.render (react-dom-server.browser.production.min.js:47)
    at e.t.read (react-dom-server.browser.production.min.js:44)
    at Object.renderToString (react-dom-server.browser.production.min.js:53)
    at Object.previewRender (form-field.jsx:186)
    at Object.F [as action] (easymde.js:893)
    at HTMLButtonElement.e.action.function.e.action.t.onclick (easymde.js:2263)

Expected behavior The preview renders correctly with the link, like it does with http urls

System Configuration

JonFStr commented 4 years ago

Additionally, if you have some text in a line before that link and have a space after the link,

hello world
<lbry://@lbry#3f/googlebanslbry#7> a

it throws another error: URL can not include a space

Again, this works flawless with http links

tzarebczan commented 4 years ago

Thanks for filing the issue!

@infinite-persistence I know you made a fix to this a while ago - is it supposed to show the content or just not fail to show the rest of the markdown?

infinite-persistence commented 4 years ago

Ah, I only handled the following format (which places a stub over it) ....

<iframe src="lbry://@lbry#3f/befreeonlbry#5"></iframe>

... since that is the format mentioned in https://lbry.com/faq/embed.

Is <lbry://xxx> a supported format?

infinite-persistence commented 4 years ago

Ah, this one's not about embeds, but treating lbry:// as a direct link. I'll take a look.

tzarebczan commented 4 years ago

It's not, so maybe that's the issue. We should handle the links - please confirm and then close.

@JonFStr Is not a valid syntax, see lbry.com/faq/embed

JonFStr commented 4 years ago

@tzarebczan I don't want to embed it but use it as a link and the angle brackets are a valid Markdown format for creating a link with the link text being the same as the URL

tzarebczan commented 4 years ago

Don't think that's supported in markdown for non-http URLs unfortunately. Maybe something we can support in the future. For now, use without the angle brackets.