From cb5e83ed31f009ea24cdca038a6c49390451cb34 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Fri, 21 May 2021 13:16:26 +0300 Subject: Added -u,--url-or-search command line option Opening an URL or making a search query from the command line. IssueID #232 --- src/gmutil.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/gmutil.c') diff --git a/src/gmutil.c b/src/gmutil.c index 2c9ba4eb..3ca93901 100644 --- a/src/gmutil.c +++ b/src/gmutil.c @@ -262,7 +262,20 @@ void urlEncodePath_String(iString *d) { delete_String(encoded); } -static iBool isSupportedUrlScheme_Rangecc_(iRangecc scheme) { +iBool isKnownScheme_Rangecc(iRangecc scheme) { + if (isKnownUrlScheme_Rangecc(scheme)) { + return iTrue; + } + static const char *uriSchemes[] = { "about", "data" }; + iForIndices(i, uriSchemes) { + if (equalCase_Rangecc(scheme, uriSchemes[i])) { + return iTrue; + } + } + return iFalse; +} + +iBool isKnownUrlScheme_Rangecc(iRangecc scheme) { static const char *schemes[] = { "gemini", "gopher", "finger", "http", "https", "file" }; iForIndices(i, schemes) { if (equalCase_Rangecc(scheme, schemes[i])) { @@ -277,7 +290,7 @@ const iString *absoluteUrl_String(const iString *d, const iString *urlMaybeRelat iUrl rel; init_Url(&orig, d); init_Url(&rel, urlMaybeRelative); - if (!isEmpty_Range(&rel.scheme) && !isSupportedUrlScheme_Rangecc_(rel.scheme) && + if (!isEmpty_Range(&rel.scheme) && !isKnownUrlScheme_Rangecc(rel.scheme) && isEmpty_Range(&rel.host)) { /* Probably not an URL, so we can't make this absolute. */ return urlMaybeRelative; -- cgit v1.2.3