Support local file urls

This commit is contained in:
Mike Sharov 2022-02-14 09:41:55 -05:00
parent bcac5268b9
commit 66f56d699b
1 changed files with 13 additions and 6 deletions

View File

@ -160,12 +160,19 @@ int UIAddFeed (char* newurl)
CleanupString (url, false);
// Support that stupid feed:// "protocol"
if (strncasecmp (url, "feed://", 7) == 0)
memcpy (url, "http", 4);
// If URL does not start with the procotol specification, assume http://
if (strncasecmp (url, "http://", 7) != 0 && strncasecmp (url, "https://", 8) != 0 && strncasecmp (url, "exec:", 5) != 0) {
if (url[0] == '/') {
// Prefix file paths with file://
char* fileurl = malloc (strlen ("file://") + strlen (url) + 1);
sprintf (fileurl, "file://%s", url);
free (url);
url = fileurl;
} else if (strncasecmp (url, "feed://", 7) == 0)
memcpy (url, "http", 4); // feed:// is http
else if (strncasecmp (url, "http://", 7) != 0
&& strncasecmp (url, "https://", 8) != 0
&& strncasecmp (url, "file://", 7) != 0
&& strncasecmp (url, "exec:", 5) != 0) {
// If URL does not start with the procotol specification, assume http://
char* httpurl = malloc (strlen ("http://") + strlen (url) + 1);
sprintf (httpurl, "http://%s", url);
free (url);