summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Base/URL.cpp')
-rw-r--r--Swiften/Base/URL.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/Swiften/Base/URL.cpp b/Swiften/Base/URL.cpp
index 4a47a11..5c0f0d7 100644
--- a/Swiften/Base/URL.cpp
+++ b/Swiften/Base/URL.cpp
@@ -1,3 +1,3 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
@@ -13,3 +13,3 @@ namespace Swift {
-int URL::getPortOrDefaultPort(const URL& url) {
+unsigned short URL::getPortOrDefaultPort(const URL& url) {
if (url.getPort()) {
@@ -64,3 +64,3 @@ URL URL::fromString(const std::string& urlString) {
std::string host;
- boost::optional<int> port;
+ boost::optional<unsigned short> port;
if (hostAndPort[0] == '[') {
@@ -73,5 +73,5 @@ URL URL::fromString(const std::string& urlString) {
try {
- port = boost::lexical_cast<int>(hostAndPort.substr(colonIndex + 1));
+ port = boost::numeric_cast<unsigned short>(boost::lexical_cast<int>(hostAndPort.substr(colonIndex + 1)));
}
- catch (const boost::bad_lexical_cast&) {
+ catch (...) {
return URL();
@@ -89,3 +89,3 @@ URL URL::fromString(const std::string& urlString) {
try {
- port = boost::lexical_cast<int>(hostAndPort.substr(colonIndex + 1));
+ port = boost::numeric_cast<unsigned short>(boost::lexical_cast<int>(hostAndPort.substr(colonIndex + 1)));
}
@@ -134,3 +134,3 @@ std::string URL::toString() const {
result += ":";
- result += boost::lexical_cast<std::string>(*port);
+ result += std::to_string(*port);
}