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:
+15
-2
@@ -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;
|
||||
|
||||
|
||||
@@ -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_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user