vicariousdrama / cornychat

🌽 Corny Chat is an open source audio space built on Jam that integrates Nostr and Lightning
https://cornychat.com
GNU Affero General Public License v3.0
19 stars 6 forks source link

Add links #58

Closed jmcudd closed 4 months ago

jmcudd commented 4 months ago

Links now work. I intentionally do not link any query parameters because they often container trackers. If someone really wants to view the link with the full query parameters, they can copy paste the full url. Also I simplified the bold and italic logic to cut out the while loops.

vicariousdrama commented 4 months ago

This is nice. Should add this to the anchor tag

target="_blank"

jmcudd commented 4 months ago

This is nice. Should add this to the anchor tag

target="_blank"

Done

vicariousdrama commented 4 months ago

And need to handle the querystrings better

input: https://example.com/dir/page.html?key=value&key2=value2

currently renders like this as the ampersand got encoded earlier https://example.com/dir/page.html?key=value&key2=value2`

jmcudd commented 4 months ago

How should they be handled? Should they be dropped all together or included in the link? I render then in the event that someone wants to use them. Perhaps I could have two links, one with no queries and one with the queries.

input: https://example.com/dir/page.html?key=value&key2=value2

output:

<a href="https://example.com/dir/page.html">https://example.com/dir/page.html</a><a href="https://example.com/dir/page.html?key=value&key2=value2">?key=value&key2=value2</a>
vicariousdrama commented 4 months ago

I think its better if one link is presented. And having the querystring parameters outside the link is a nice touch. Just want the encoding to support easier copying without needing to edit the encoding of ampersands dividing the parameters.

jmcudd commented 4 months ago

Here is the approach I'm suggesting. I'll merge it into this PR if you like it. https://github.com/jmcudd/cornychat/pull/1

vicariousdrama commented 4 months ago

That's actually better what you have in https://github.com/jmcudd/cornychat/pull/1

jmcudd commented 4 months ago

2024-04-25_01-44 17

Links will look like this.

jmcudd commented 4 months ago

Be sure to test bold and italic in this PR, it is different.

vicariousdrama commented 4 months ago

Yeah, the bold and italics are good. Also gives me ideas that it may be feasible to integrate NIP-30 custom emojis eventually.

vicariousdrama commented 4 months ago

Lines 87-89 aren't necessary since escaping was already performed on line 69. This is also escaping HTML, and if anything, may need to URI encode.

However, that should already be done by someone copy/pasting in, and there's no harm in not performing further treatment. For example, if a user provided the following url

https://example.com/file?var=123&var2=78%&var3=w%w%

we wouldn't want to double encode the entire querystring as

https://example.com/file?var%3D123%26var2%3D78%25%26var3%3Dw%25w%25

nor would we want to do on just the values as

https://example.com/file?var=123&var2=78%25&var3=w%25w%25

vicariousdrama commented 4 months ago

Looks good