UrlProvider: Introduce combine(), rootUrl(), atomFeed()

Tento commit je obsažen v:
Albert S. 2022-03-27 19:51:53 +02:00
rodič 9520aabe5c
revize bcc3737d88
2 změnil soubory, kde provedl 32 přidání a 0 odebrání

Zobrazit soubor

@ -18,6 +18,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#include <string_view>
#include "urlprovider.h" #include "urlprovider.h"
std::string replaceSingleVar(std::string where, std::string varname, std::string replacement) std::string replaceSingleVar(std::string where, std::string varname, std::string replacement)
@ -119,3 +120,28 @@ std::string UrlProvider::login(std::string page)
{ {
return replaceOnlyPage(config->loginurl, page); return replaceOnlyPage(config->loginurl, page);
} }
std::string UrlProvider::rootUrl()
{
return config->rooturl;
}
std::string UrlProvider::atomFeed(std::string filter)
{
return combine({config->rooturl, replaceSingleVar(config->atomurl, "filter", filter)});
}
std::string UrlProvider::combine(std::initializer_list<std::string> urls)
{
std::string result;
for(const std::string &url : urls)
{
std::string_view urlview{url};
if(result.back() == '/' && urlview.front() == '/')
{
urlview.remove_prefix(1);
}
result += urlview;
}
return result;
}

Zobrazit soubor

@ -48,6 +48,12 @@ class UrlProvider
std::string category(std::string catname); std::string category(std::string catname);
std::string login(std::string page); std::string login(std::string page);
std::string rootUrl();
std::string atomFeed(std::string filter);
std::string combine(std::initializer_list<std::string> urls);
}; };
#endif // LINKCREATOR_H #endif // LINKCREATOR_H