diff --git a/connector/syncthingconfig.cpp b/connector/syncthingconfig.cpp index 3f276b3..32b1847 100644 --- a/connector/syncthingconfig.cpp +++ b/connector/syncthingconfig.cpp @@ -87,7 +87,7 @@ bool SyncthingConfig::restore(const QString &configFilePath) QString SyncthingConfig::syncthingUrl() const { - return (guiEnforcesSecureConnection || !isLocal(guiAddress) ? QStringLiteral("https://") : QStringLiteral("http://")) + guiAddress; + return (guiEnforcesSecureConnection || !isLocal(stripPort(guiAddress)) ? QStringLiteral("https://") : QStringLiteral("http://")) + guiAddress; } } // namespace Data diff --git a/connector/utils.cpp b/connector/utils.cpp index b03e843..cc66c02 100644 --- a/connector/utils.cpp +++ b/connector/utils.cpp @@ -104,6 +104,15 @@ QString rescanIntervalString(int rescanInterval, bool fileSystemWatcherEnabled) : QCoreApplication::translate("Data::Utils", ", file system watcher disabled")); } +/*! + * \brief Strips the port from the specified \a address. + */ +QString stripPort(const QString &address) +{ + const auto portStart = address.lastIndexOf(QChar(':')); + return portStart < 0 ? address : address.mid(0, portStart); +} + /*! * \brief Returns whether the specified \a hostName is the local machine. */ diff --git a/connector/utils.h b/connector/utils.h index 6d67364..67c03e6 100644 --- a/connector/utils.h +++ b/connector/utils.h @@ -33,6 +33,7 @@ LIB_SYNCTHING_CONNECTOR_EXPORT QString directoryStatusString(const Data::Syncthi LIB_SYNCTHING_CONNECTOR_EXPORT QString syncCompleteString( const std::vector &completedDirs, const SyncthingDev *remoteDevice = nullptr); LIB_SYNCTHING_CONNECTOR_EXPORT QString rescanIntervalString(int rescanInterval, bool fileSystemWatcherEnabled); +LIB_SYNCTHING_CONNECTOR_EXPORT QString stripPort(const QString &address); LIB_SYNCTHING_CONNECTOR_EXPORT bool isLocal(const QString &hostName); LIB_SYNCTHING_CONNECTOR_EXPORT bool isLocal(const QString &hostName, const QHostAddress &hostAddress); LIB_SYNCTHING_CONNECTOR_EXPORT bool setDirectoriesPaused(QJsonObject &syncthingConfig, const QStringList &dirIds, bool paused);