diff --git a/src/common/kiwix/reader.cpp b/src/common/kiwix/reader.cpp index 2036d0c75..e6e7f2e42 100644 --- a/src/common/kiwix/reader.cpp +++ b/src/common/kiwix/reader.cpp @@ -380,6 +380,11 @@ namespace kiwix { } bool Reader::getContentByDecodedUrl(const string &url, string &content, unsigned int &contentLength, string &contentType) { + std::string stubRedirectUrl; + return this->getContentByDecodedUrl(kiwix::urlDecode(url), content, contentLength, contentType, stubRedirectUrl); + } + + bool Reader::getContentByDecodedUrl(const string &url, string &content, unsigned int &contentLength, string &contentType, string &baseUrl) { bool retVal = false; content=""; contentType=""; @@ -411,6 +416,9 @@ namespace kiwix { article = article.getRedirectArticle(); } + /* Compute base url (might be different from the url if redirects */ + baseUrl = "/" + std::string(1, article.getNamespace()) + "/" + article.getUrl(); + /* Get the content mime-type */ contentType = string(article.getMimeType().data(), article.getMimeType().size()); diff --git a/src/common/kiwix/reader.h b/src/common/kiwix/reader.h index b140fe5bf..a63d55006 100644 --- a/src/common/kiwix/reader.h +++ b/src/common/kiwix/reader.h @@ -63,6 +63,7 @@ namespace kiwix { bool getPageUrlFromTitle(const string &title, string &url); bool getContentByUrl(const string &url, string &content, unsigned int &contentLength, string &contentType); bool getContentByEncodedUrl(const string &url, string &content, unsigned int &contentLength, string &contentType); + bool getContentByDecodedUrl(const string &url, string &content, unsigned int &contentLength, string &contentType, string &baseUrl); bool getContentByDecodedUrl(const string &url, string &content, unsigned int &contentLength, string &contentType); bool searchSuggestions(const string &prefix, unsigned int suggestionsCount, const bool reset = true); bool searchSuggestionsSmart(const string &prefix, unsigned int suggestionsCount);