Open snunez1 opened 3 years ago
Good question, I don't think quri provides such a validation function. Correct me if I'm wrong.
Nyxt did implement its own though:
https://github.com/atlas-engineer/nyxt/blob/2.2.0/source/urls.lisp#L76
I don't think it's exactly RFC 3986, so we might have to update it a little.
Then shall we merge it into quri?
That would work well, thanks.
Just came back to see if this was closed. Although the Nyxt implementation and RFC 3986 are unquestionably better solutions, perhaps a quick & dirty checking for http(s) would suffice? That's what I've been using and so far it does the job.
Sorry, I haven't had time to dedicate to quri.
Pull requests are welcome!
Is there a way of detecting a valid URI given a string representation?
The use case is this: I have a function that takes multiple input sources and dispatches on the type; stream, string, pathname at the moment. For URLs we have to turn them into a stream at the function invocation level with (dex:get ... :want-stream t) and this is getting tedious as the number of internet based input sources increases.
The challenge is in passing the URI as a string: how do we know that the string is for input itself or designates a URI to retrieve? For this purpose, it is sufficient to detect a valid URI, say RFC 3986, and if it is get a stream via dex, and if it's not a valid URI use the string as input. Something like
valid-uri-p
or similar would be perfect, but I didn't see anything like this in the code.Is there any way of doing this with quri?