diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-23 11:58:10 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-23 11:58:10 +0200 |
commit | 456ca26906e84e3cadd670328ed5dca7718da50c (patch) | |
tree | 95b7b5dd7429003d6333d421975f796becf440ba /src/ui | |
parent | 78092e44e6ba554c6ed31df5bfa3d7c38d2341d2 (diff) |
"Go to Root" respects user names in URL
The behavior of navigating to root should match what is displayed in the top banner.
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/documentwidget.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 2e81838f..146b0de7 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -1025,17 +1025,7 @@ static void updateTrust_DocumentWidget_(iDocumentWidget *d, const iGmResponse *r | |||
1025 | } | 1025 | } |
1026 | 1026 | ||
1027 | static void parseUser_DocumentWidget_(iDocumentWidget *d) { | 1027 | static void parseUser_DocumentWidget_(iDocumentWidget *d) { |
1028 | clear_String(d->titleUser); | 1028 | setRange_String(d->titleUser, urlUser_String(d->mod.url)); |
1029 | iRegExp *userPats[2] = { new_RegExp("~([^/?]+)", 0), | ||
1030 | new_RegExp("/users/([^/?]+)", caseInsensitive_RegExpOption) }; | ||
1031 | iRegExpMatch m; | ||
1032 | init_RegExpMatch(&m); | ||
1033 | iForIndices(i, userPats) { | ||
1034 | if (matchString_RegExp(userPats[i], d->mod.url, &m)) { | ||
1035 | setRange_String(d->titleUser, capturedRange_RegExpMatch(&m, 1)); | ||
1036 | } | ||
1037 | iRelease(userPats[i]); | ||
1038 | } | ||
1039 | } | 1029 | } |
1040 | 1030 | ||
1041 | static iBool updateFromHistory_DocumentWidget_(iDocumentWidget *d) { | 1031 | static iBool updateFromHistory_DocumentWidget_(iDocumentWidget *d) { |
@@ -1956,9 +1946,14 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
1956 | else if (equal_Command(cmd, "navigate.root") && document_App() == d) { | 1946 | else if (equal_Command(cmd, "navigate.root") && document_App() == d) { |
1957 | iUrl parts; | 1947 | iUrl parts; |
1958 | init_Url(&parts, d->mod.url); | 1948 | init_Url(&parts, d->mod.url); |
1949 | const char *rootEnd = parts.path.start; | ||
1950 | const iRangecc user = urlUser_String(d->mod.url); | ||
1951 | if (!isEmpty_Range(&user)) { | ||
1952 | rootEnd = user.end; | ||
1953 | } | ||
1959 | postCommandf_App( | 1954 | postCommandf_App( |
1960 | "open url:%s/", | 1955 | "open url:%s/", |
1961 | cstr_Rangecc((iRangecc){ constBegin_String(d->mod.url), parts.path.start })); | 1956 | cstr_Rangecc((iRangecc){ constBegin_String(d->mod.url), rootEnd })); |
1962 | return iTrue; | 1957 | return iTrue; |
1963 | } | 1958 | } |
1964 | else if (equalWidget_Command(cmd, w, "scroll.moved")) { | 1959 | else if (equalWidget_Command(cmd, w, "scroll.moved")) { |