Check if a string looks like a URL.
isUrl(target)
if (isUrl(input)) {
await download(input, urlToFilepath(input));
}
The check is pretty loose (basically checks if starts with https?://
), and
would validate strings that wouldn't pass a more strict format.