UrlProvider: Introduce combine(), rootUrl(), atomFeed()
This commit is contained in:
parent
9520aabe5c
commit
bcc3737d88
@ -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;
|
||||||
|
}
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user