So in another part of my program I read out various urls from my browser.
Say I have http://www.example.com
as well as http://example.com
and https://example.com
. For a browser, these three urls are different.
To me, only the 'base' domain (example.com
) is important.
I now am trying to strip the www
from the domain, however, can not succeed. I'd like to do so using the provided QUrl library instead of checking whether the string includes a www.
and remove it afterwards.
As you can see, it's more of a design-decision here ;)
Here's my current application.
main.cpp
#include <QApplication>
#include <QDebug>
#include <QUrl>
#include <QList>
int main(int argc, char *argv[])
{
QList<QUrl> urlList;
urlList << QUrl("http://example.com/qwe/whoami/123#123141");
urlList << QUrl("chrome://newtab/");
urlList << QUrl("favorites://");
urlList << QUrl("");
urlList << QUrl("https://www.google.de/");
urlList << QUrl("https://google.de/");
urlList << QUrl("https://www.youtube.com/watch?v=XTPGpBBqwe");
urlList << QUrl("https://youtube.com/watch?v=189273ijadzqiuwejk");
urlList << QUrl("http://raspberrypi.stackexchange.com/questions/10371/whoisthisyo");
urlList << QUrl("https://stackoverflow.com/questions/33478464/alfresco-custom");
urlList << QUrl("http://localhost:3000");
urlList << QUrl("localhost:3000");
for (int i = 0; i < urlList.count(); i++) {
qDebug() << "[" << i+1 << "] " << urlList[i].host();
}
return 0;
}
Thanks for your help!