diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-08 13:27:54 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-08 13:27:54 +0200 |
commit | 492e8257afa8f1e2183f1c7031fd7340a66cbc6e (patch) | |
tree | d181c9b8d519ed9fb7795bdc72e922aae942d2d8 /src | |
parent | b930af02e7144b326af1b963bcea0e3b5e4ca304 (diff) |
Bookmarks: Do not require a label for remote links
IssueID #147
Diffstat (limited to 'src')
-rw-r--r-- | src/bookmarks.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/bookmarks.c b/src/bookmarks.c index be5e426f..2efdc873 100644 --- a/src/bookmarks.c +++ b/src/bookmarks.c | |||
@@ -389,7 +389,7 @@ void requestFinished_Bookmarks(iBookmarks *d, iGmRequest *req) { | |||
389 | if (isSuccess_GmStatusCode(status_GmRequest(req))) { | 389 | if (isSuccess_GmStatusCode(status_GmRequest(req))) { |
390 | iTime now; | 390 | iTime now; |
391 | initCurrent_Time(&now); | 391 | initCurrent_Time(&now); |
392 | iRegExp *linkPattern = new_RegExp("^=>\\s*([^\\s]+)\\s+(.*)", 0); | 392 | iRegExp *linkPattern = new_RegExp("^=>\\s*([^\\s]+)(\\s+(.*))?", 0); |
393 | iString src; | 393 | iString src; |
394 | const iString *remoteTag = collectNewCStr_String("remote"); | 394 | const iString *remoteTag = collectNewCStr_String("remote"); |
395 | initBlock_String(&src, body_GmRequest(req)); | 395 | initBlock_String(&src, body_GmRequest(req)); |
@@ -401,11 +401,14 @@ void requestFinished_Bookmarks(iBookmarks *d, iGmRequest *req) { | |||
401 | init_RegExpMatch(&m); | 401 | init_RegExpMatch(&m); |
402 | if (matchRange_RegExp(linkPattern, line, &m)) { | 402 | if (matchRange_RegExp(linkPattern, line, &m)) { |
403 | const iRangecc url = capturedRange_RegExpMatch(&m, 1); | 403 | const iRangecc url = capturedRange_RegExpMatch(&m, 1); |
404 | const iRangecc title = capturedRange_RegExpMatch(&m, 2); | 404 | const iRangecc title = capturedRange_RegExpMatch(&m, 3); |
405 | iString * urlStr = newRange_String(url); | 405 | iString * urlStr = newRange_String(url); |
406 | const iString *absUrl = absoluteUrl_String(url_GmRequest(req), urlStr); | 406 | const iString *absUrl = absoluteUrl_String(url_GmRequest(req), urlStr); |
407 | if (!findUrl_Bookmarks(d, absUrl)) { | 407 | if (!findUrl_Bookmarks(d, absUrl)) { |
408 | iString *titleStr = newRange_String(title); | 408 | iString *titleStr = newRange_String(title); |
409 | if (isEmpty_String(titleStr)) { | ||
410 | setRange_String(titleStr, urlHost_String(urlStr)); | ||
411 | } | ||
409 | const uint32_t bmId = add_Bookmarks(d, absUrl, titleStr, remoteTag, 0x2913); | 412 | const uint32_t bmId = add_Bookmarks(d, absUrl, titleStr, remoteTag, 0x2913); |
410 | iBookmark *bm = get_Bookmarks(d, bmId); | 413 | iBookmark *bm = get_Bookmarks(d, bmId); |
411 | bm->sourceId = *(uint32_t *) userData_Object(req); | 414 | bm->sourceId = *(uint32_t *) userData_Object(req); |