Allow building with -Wmissing-noreturn
[folly.git] / folly / Uri-inl.h
index e9ec73215f8269080423e1561b9b9aa32ac9ee54..3132f10fa35e78f667b60a32ac3c6b457ed5ea4b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Facebook, Inc.
+ * Copyright 2016 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,15 +25,19 @@ namespace folly {
 template <class String>
 String Uri::toString() const {
   String str;
-  toAppend(scheme_, "://", &str);
-  if (!password_.empty()) {
-    toAppend(username_, ":", password_, "@", &str);
-  } else if (!username_.empty()) {
-    toAppend(username_, "@", &str);
-  }
-  toAppend(host_, &str);
-  if (port_ != 0) {
-    toAppend(":", port_, &str);
+  if (hasAuthority_) {
+    toAppend(scheme_, "://", &str);
+    if (!password_.empty()) {
+      toAppend(username_, ":", password_, "@", &str);
+    } else if (!username_.empty()) {
+      toAppend(username_, "@", &str);
+    }
+    toAppend(host_, &str);
+    if (port_ != 0) {
+      toAppend(":", port_, &str);
+    }
+  } else {
+    toAppend(scheme_, ":", &str);
   }
   toAppend(path_, &str);
   if (!query_.empty()) {