diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-23 11:46:18 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-23 11:46:18 +0200 |
commit | 64b9cea544ecb2c0ae95afae5e84543ac6117f62 (patch) | |
tree | dbe2f0e2a462a14449c3053fdc30ccaf701782e7 /src/bookmarks.c | |
parent | 5d8bfceb00d5d6b358b358b76c5828344c179e5d (diff) |
Improved handling of bookmark icons
The effect of a bookmark icon is restricted to URLs that begin with the bookmarked URL.
TODO: Bookmark icon of an URL should affect the whole domain, but this should take into consideration user subdirectories ("~name" or "/users/name").
IssueID #140
Diffstat (limited to 'src/bookmarks.c')
-rw-r--r-- | src/bookmarks.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/bookmarks.c b/src/bookmarks.c index 7560a24c..60048d36 100644 --- a/src/bookmarks.c +++ b/src/bookmarks.c | |||
@@ -250,8 +250,12 @@ iBool updateBookmarkIcon_Bookmarks(iBookmarks *d, const iString *url, iChar icon | |||
250 | return changed; | 250 | return changed; |
251 | } | 251 | } |
252 | 252 | ||
253 | iChar siteIcon_Bookmarks(const iBookmarks *d, iRangecc hostName) { | 253 | iChar siteIcon_Bookmarks(const iBookmarks *d, const iString *url) { |
254 | if (isEmpty_String(url)) { | ||
255 | return 0; | ||
256 | } | ||
254 | iChar icon = 0; | 257 | iChar icon = 0; |
258 | iRangecc hostName = urlHost_String(url); | ||
255 | const size_t hostSize = size_Range(&hostName); | 259 | const size_t hostSize = size_Range(&hostName); |
256 | size_t matchingSize = iInvalidSize; /* we'll pick the shortest matching */ | 260 | size_t matchingSize = iInvalidSize; /* we'll pick the shortest matching */ |
257 | lock_Mutex(d->mtx); | 261 | lock_Mutex(d->mtx); |
@@ -265,6 +269,9 @@ iChar siteIcon_Bookmarks(const iBookmarks *d, iRangecc hostName) { | |||
265 | if (size_Range(&hostName) == size_Range(&parts.host) && | 269 | if (size_Range(&hostName) == size_Range(&parts.host) && |
266 | iCmpStrNCase(hostName.start, parts.host.start, hostSize) == 0) { | 270 | iCmpStrNCase(hostName.start, parts.host.start, hostSize) == 0) { |
267 | const size_t n = size_String(&bm->url); | 271 | const size_t n = size_String(&bm->url); |
272 | if (n > size_String(url)) { | ||
273 | continue; /* Bookmark must be higher up in the path tree. */ | ||
274 | } | ||
268 | if (n < matchingSize && bm->icon) { | 275 | if (n < matchingSize && bm->icon) { |
269 | matchingSize = n; | 276 | matchingSize = n; |
270 | icon = bm->icon; | 277 | icon = bm->icon; |