I am creating a CLI tool that can take either a URL or a path as its argument. How do I detect whether a string is a URL or a path?
I am specifically talking about detecting absolute URLs like:
Versus paths like:
I was thinking of using the url crate which has a function
Url::parse that only parses absolute URLs and then defaulting to a path if that returns
ParseError::RelativeUrlWithoutBase. Is there a better/more lightweight way to do this? I know URL parsing can be tricky so I am defaulting to not doing it myself.