import: allow file:// in addition to HTTP(S)

Previously we only allows http/https urls, let's open this up a bit.
Why? Because it makes testing *so* *much* *easier* as we don't need to
run a HTTP server all the time.

CURL mostly abstracts the differences of http/https away from us, hence
we can get away with very little extra work.
This commit is contained in:
Lennart Poettering
2021-08-20 21:56:39 +02:00
parent 55b90ee00b
commit c456862f87
8 changed files with 67 additions and 41 deletions
+15 -2
View File
@@ -36,16 +36,29 @@ bool http_url_is_valid(const char *url) {
return ascii_is_valid(p);
}
bool file_url_is_valid(const char *url) {
const char *p;
if (isempty(url))
return false;
p = startswith(url, "file:/");
if (isempty(p))
return false;
return ascii_is_valid(p);
}
bool documentation_url_is_valid(const char *url) {
const char *p;
if (isempty(url))
return false;
if (http_url_is_valid(url))
if (http_url_is_valid(url) || file_url_is_valid(url))
return true;
p = STARTSWITH_SET(url, "file:/", "info:", "man:");
p = STARTSWITH_SET(url, "info:", "man:");
if (isempty(p))
return false;
+1
View File
@@ -6,6 +6,7 @@
#include "macro.h"
bool http_url_is_valid(const char *url) _pure_;
bool file_url_is_valid(const char *url) _pure_;
bool documentation_url_is_valid(const char *url) _pure_;