linkify icon indicating copy to clipboard operation
linkify copied to clipboard

This one doesn't parse out the link right

Open mikedilger opened this issue 2 years ago • 3 comments

An example that isn't parsing out right. Scheme can't have a '.' in it, right?

Just to show.. this is the list of relays that have seen this post.https://nostr.build/i/1105.png

mikedilger avatar Jan 01 '23 18:01 mikedilger

It can, according to 3.1. Scheme:

Scheme names consist of a sequence of characters beginning with a letter and followed by any combination of letters, digits, plus ("+"), period ("."), or hyphen ("-").

It cannot start with a period, which means post .https://nostr.build/i/1105.png results in the "expected" output but post.https://nostr.build/i/1105.png does not since post.https is a valid scheme name.

I think a worthwhile feature for this library is to allow restricting schemes, since I would prefer matching https://nostr.build/i/1105.png in this case as well.

kosayoda avatar Jan 01 '23 18:01 kosayoda

I stand corrected.

mikedilger avatar Jan 01 '23 18:01 mikedilger

Yeah. I think having an option to provide an allow-list of schemes to recognize would be nice (added a "help wanted" label). You could pass in https, http and it would only return URLs with that (and stop at characters like . or +). It's a bit trickier than that because you could also provide post.https and https and in that case it should probably use the longer match.

robinst avatar Jan 05 '23 00:01 robinst