diff --git a/ChangeLog b/ChangeLog index aa9a687..217661d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2020-11-18 Omar Polo + + * gmid.c (url_after_proto): correct url parsing: accept URLs + without explicit protocol + 2020-11-17 Omar Polo * gmid.c (main): add flag -p to change the port diff --git a/gmid.c b/gmid.c index 87a4a62..d0f03a7 100644 --- a/gmid.c +++ b/gmid.c @@ -172,19 +172,25 @@ url_after_proto(char *url) { char *s; const char *proto = "gemini"; - const char *marker = "://"; + const char *marker = "//"; /* a relative URL */ if ((s = strstr(url, marker)) == NULL) return url; + /* + * if a protocol is not specified, gemini should be implied: + * this handles the case of //example.com + */ + if (s == url) + return s + strlen(marker); + if (s - strlen(proto) != url) return NULL; if (!starts_with(url, proto)) return NULL; - /* a valid gemini:// URL */ return s + strlen(marker); }