commit - 721e2325296b1556eb0d2224ef37b387091dff43
commit + ae2ad03ec0ae5f2300472239eb48f3e23d467fe2
blob - aa9a687625b4185962c750cd2190877096e3b043
blob + 217661d06130dc8766a433b0ec1618acedade1a1
--- ChangeLog
+++ ChangeLog
+2020-11-18 Omar Polo <op@omarpolo.com>
+
+ * gmid.c (url_after_proto): correct url parsing: accept URLs
+ without explicit protocol
+
2020-11-17 Omar Polo <op@omarpolo.com>
* gmid.c (main): add flag -p to change the port
blob - 87a4a622f653d350c159d42ba91c6265129d3fd7
blob + d0f03a7db9ba906f262702ffaf33398ee0d23b13
--- gmid.c
+++ gmid.c
{
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);
}