mirror of https://github.com/omar-polo/gmid.git
handle //example.com urls
This commit is contained in:
parent
721e232529
commit
ae2ad03ec0
|
@ -1,3 +1,8 @@
|
|||
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
|
||||
|
|
10
gmid.c
10
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue