mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 18:40:05 +00:00
37 lines
661 B
C++
37 lines
661 B
C++
#include <scwx/qt/util/network.hpp>
|
|
|
|
#include <QDir>
|
|
#include <QUrl>
|
|
|
|
namespace scwx
|
|
{
|
|
namespace qt
|
|
{
|
|
namespace util
|
|
{
|
|
namespace network
|
|
{
|
|
|
|
std::string NormalizeUrl(const std::string& urlString)
|
|
{
|
|
std::string normalizedUrl;
|
|
|
|
// Normalize URL string
|
|
QString trimmedUrlString = QString::fromStdString(urlString).trimmed();
|
|
QUrl url = QUrl::fromUserInput(trimmedUrlString);
|
|
if (url.isLocalFile())
|
|
{
|
|
normalizedUrl = QDir::toNativeSeparators(url.toLocalFile()).toStdString();
|
|
}
|
|
else
|
|
{
|
|
normalizedUrl = urlString;
|
|
}
|
|
|
|
return normalizedUrl;
|
|
}
|
|
|
|
} // namespace network
|
|
} // namespace util
|
|
} // namespace qt
|
|
} // namespace scwx
|