diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-01-12 12:02:07 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-01-12 12:02:07 +0200 |
commit | a573d5155d0c9554789124d8d02ed83bd21ec46e (patch) | |
tree | b44b1ba5dbf31bad22d5c00d9e3452d187e59479 /src | |
parent | 964b9f752f086f58a6aae2602e83b30833412199 (diff) |
Feeds: Strip default Gemini ports from URLs
Diffstat (limited to 'src')
-rw-r--r-- | src/feeds.c | 1 | ||||
-rw-r--r-- | src/gmutil.c | 10 | ||||
-rw-r--r-- | src/gmutil.h | 1 |
3 files changed, 12 insertions, 0 deletions
diff --git a/src/feeds.c b/src/feeds.c index 0f06e33d..75173ee1 100644 --- a/src/feeds.c +++ b/src/feeds.c | |||
@@ -509,6 +509,7 @@ static void load_Feeds_(iFeeds *d) { | |||
509 | entry->posted.ts.tv_sec = posted; | 509 | entry->posted.ts.tv_sec = posted; |
510 | entry->discovered.ts.tv_sec = discovered; | 510 | entry->discovered.ts.tv_sec = discovered; |
511 | set_String(&entry->url, url); | 511 | set_String(&entry->url, url); |
512 | stripDefaultUrlPort_String(&entry->url); | ||
512 | set_String(&entry->title, title); | 513 | set_String(&entry->title, title); |
513 | insert_SortedArray(&d->entries, &entry); | 514 | insert_SortedArray(&d->entries, &entry); |
514 | } | 515 | } |
diff --git a/src/gmutil.c b/src/gmutil.c index a299347f..ab9a8eea 100644 --- a/src/gmutil.c +++ b/src/gmutil.c | |||
@@ -81,6 +81,16 @@ static iRangecc prevPathSeg_(const char *end, const char *start) { | |||
81 | return seg; | 81 | return seg; |
82 | } | 82 | } |
83 | 83 | ||
84 | void stripDefaultUrlPort_String(iString *d) { | ||
85 | iUrl parts; | ||
86 | init_Url(&parts, d); | ||
87 | if (equalCase_Rangecc(parts.scheme, "gemini") && equal_Rangecc(parts.port, "1965")) { | ||
88 | /* Always preceded by a colon. */ | ||
89 | remove_Block(&d->chars, parts.port.start - 1 - constBegin_String(d), | ||
90 | size_Range(&parts.port) + 1); | ||
91 | } | ||
92 | } | ||
93 | |||
84 | void cleanUrlPath_String(iString *d) { | 94 | void cleanUrlPath_String(iString *d) { |
85 | iString clean; | 95 | iString clean; |
86 | init_String(&clean); | 96 | init_String(&clean); |
diff --git a/src/gmutil.h b/src/gmutil.h index a9c8c42a..947ff56b 100644 --- a/src/gmutil.h +++ b/src/gmutil.h | |||
@@ -104,6 +104,7 @@ iRangecc urlScheme_String (const iString *); | |||
104 | iRangecc urlHost_String (const iString *); | 104 | iRangecc urlHost_String (const iString *); |
105 | const iString * absoluteUrl_String (const iString *, const iString *urlMaybeRelative); | 105 | const iString * absoluteUrl_String (const iString *, const iString *urlMaybeRelative); |
106 | void punyEncodeUrlHost_String(iString *); | 106 | void punyEncodeUrlHost_String(iString *); |
107 | void stripDefaultUrlPort_String(iString *); | ||
107 | void urlDecodePath_String (iString *); | 108 | void urlDecodePath_String (iString *); |
108 | void urlEncodePath_String (iString *); | 109 | void urlEncodePath_String (iString *); |
109 | iString * makeFileUrl_String (const iString *localFilePath); | 110 | iString * makeFileUrl_String (const iString *localFilePath); |