Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idiomatic way of detecting valid URI? #57

Open
snunez1 opened this issue Sep 24, 2021 · 4 comments
Open

Idiomatic way of detecting valid URI? #57

snunez1 opened this issue Sep 24, 2021 · 4 comments

Comments

@snunez1
Copy link

snunez1 commented Sep 24, 2021

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?

@Ambrevar
Copy link
Collaborator

Ambrevar commented Sep 24, 2021 via email

@snunez1 snunez1 changed the title Idomatic way of detecting valid URI? Idiomatic way of detecting valid URI? Sep 24, 2021
@snunez1
Copy link
Author

snunez1 commented Sep 25, 2021

That would work well, thanks.

@snunez1
Copy link
Author

snunez1 commented Mar 7, 2022

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.

@Ambrevar
Copy link
Collaborator

Ambrevar commented Mar 7, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants