refactor: CoreProcess make wrapIpv6, Simplify wrapIpV6 method
This commit is contained in:
committed by
Chris Rizzitello
parent
de6be901b9
commit
ac7bd1ceca
@ -66,23 +66,27 @@ QString CoreProcess::makeQuotedArgs(const QString &app, const QStringList &args)
|
||||
/**
|
||||
* @brief If IPv6, ensures the IP is surround in square brackets.
|
||||
*/
|
||||
QString wrapIpv6(const QString &address)
|
||||
QString CoreProcess::wrapIpv6(const QString &address)
|
||||
{
|
||||
if (!address.contains(':') || address.isEmpty()) {
|
||||
static const auto colon = QStringLiteral(":");
|
||||
static const auto openBracket = QStringLiteral("[");
|
||||
static const auto closeBracket = QStringLiteral("]");
|
||||
|
||||
if (!address.contains(colon) || address.isEmpty()) {
|
||||
return address;
|
||||
}
|
||||
|
||||
QString wrapped = address;
|
||||
|
||||
if (address[0] != '[') {
|
||||
wrapped.insert(0, '[');
|
||||
if (!address.startsWith(openBracket)) {
|
||||
wrapped.prepend(openBracket);
|
||||
}
|
||||
|
||||
if (address[address.size() - 1] != ']') {
|
||||
wrapped.push_back(']');
|
||||
if (!address.endsWith(closeBracket)) {
|
||||
wrapped.append(closeBracket);
|
||||
}
|
||||
|
||||
return address;
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@ -125,6 +125,7 @@ private:
|
||||
static QString makeQuotedArgs(const QString &app, const QStringList &args);
|
||||
static QString processModeToString(const Settings::ProcessMode mode);
|
||||
static QString processStateToString(const CoreProcess::ProcessState state);
|
||||
static QString wrapIpv6(const QString &address);
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
void checkOSXNotification(const QString &line);
|
||||
|
||||
Reference in New Issue
Block a user