From c35263939085f5f3bef0c6517afff335a55acf30 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Fri, 2 Jul 2021 14:16:46 +0300 Subject: Further canonical URIs --- src/feeds.c | 8 +++++--- src/history.c | 6 +++++- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/feeds.c b/src/feeds.c index a68fd726..3bb6ad89 100644 --- a/src/feeds.c +++ b/src/feeds.c @@ -241,7 +241,7 @@ static void parseResult_FeedJob_(iFeedJob *d) { entry->bookmarkId = d->bookmarkId; iString *title = newRange_String(line); set_String(&entry->title, title); - set_String(&entry->url, canonicalUrl_String(&d->url)); + set_String(&entry->url, canonicalUrl_String(&d->url)); appendChar_String(&entry->url, '#'); append_String(&entry->url, collect_String(urlEncode_String(title))); delete_String(title); @@ -498,8 +498,9 @@ static void load_Feeds_(iFeeds *d) { break; } case 2: { - /* TODO: All right, this could maybe use a bit more robust, structured - format. The code below is messy. */ + /* TODO: Cleanup needed... + All right, this could maybe use a bit more robust, structured format. + The code below is messy. */ const uint32_t feedId = strtoul(line.start, NULL, 16); if (!nextSplit_Rangecc(range_Block(src), "\n", &line)) { goto aborted; @@ -535,6 +536,7 @@ static void load_Feeds_(iFeeds *d) { entry->discovered.ts.tv_sec = discovered; set_String(&entry->url, url); stripDefaultUrlPort_String(&entry->url); + set_String(&entry->url, canonicalUrl_String(&entry->url)); set_String(&entry->title, title); insert_SortedArray(&d->entries, &entry); } diff --git a/src/history.c b/src/history.c index 2cea393d..208c239d 100644 --- a/src/history.c +++ b/src/history.c @@ -194,6 +194,7 @@ void deserialize_History(iHistory *d, iStream *ins) { iRecentUrl item; init_RecentUrl(&item); deserialize_String(&item.url, ins); + set_String(&item.url, canonicalUrl_String(&item.url)); item.normScrollY = (float) read32_Stream(ins) / 1.0e6f; if (version_Stream(ins) >= addedRecentUrlFlags_FileVersion) { uint16_t flags = readU16_Stream(ins); @@ -246,6 +247,7 @@ const iString *url_History(const iHistory *d, size_t pos) { } iRecentUrl *findUrl_History(iHistory *d, const iString *url) { + url = canonicalUrl_String(url); lock_Mutex(d->mtx); iReverseForEach(Array, i, &d->recent) { if (cmpStringCase_String(url, &((iRecentUrl *) i.value)->url) == 0) { @@ -258,6 +260,7 @@ iRecentUrl *findUrl_History(iHistory *d, const iString *url) { } void replace_History(iHistory *d, const iString *url) { + url = canonicalUrl_String(url); lock_Mutex(d->mtx); /* Update in the history. */ iRecentUrl *item = mostRecentUrl_History(d); @@ -267,7 +270,8 @@ void replace_History(iHistory *d, const iString *url) { unlock_Mutex(d->mtx); } -void add_History(iHistory *d, const iString *url ){ +void add_History(iHistory *d, const iString *url) { + url = canonicalUrl_String(url); lock_Mutex(d->mtx); /* Cut the trailing history items. */ if (d->recentPos > 0) { -- cgit v1.2.3