amodm / webbrowser-rs

Rust library to open URLs in the web browsers available on a platform

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

url parameter is treated as file link if the last character is a space

deg0nz opened this issue · comments

commented

I had the issue, that the URL was treated as a file link, if it contains a space at the end.

For example:

My URL is let url = "http://example.com/foo ".
When I call webbrowser::open(url), I get the error The file /path/to/current/directory/http:/example.com/foo does not exist..

Maybe there should be some kind if URL validation to determine, if the given String is actually a valid URL?
Or maybe some logic that determines, if the given str is a file path and then converts it to an actual file:// path?

Handling URL encoding/validation should be a user input stage check, than a library level check. As an example, if you were to look at python's webbrowser library, you'd find no URL encoding done either.

@deg0nz commit 11789dd should fix this. I'd made that commit for handling unicode chars, but should help here too.