X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FUri-inl.h;h=5cb1967c66fcc0705a5b50f7abb27d73603e4a7c;hb=00eb2ce00f68bdb274844f1c6bb29ca6b8bbf6cf;hp=3fb692e93c681f5c20ba8cf375a3e3d40ef1cba7;hpb=22afce906d7e98d95f8c45c3301072d9fd891d41;p=folly.git diff --git a/folly/Uri-inl.h b/folly/Uri-inl.h index 3fb692e9..5cb1967c 100644 --- a/folly/Uri-inl.h +++ b/folly/Uri-inl.h @@ -1,5 +1,5 @@ /* - * Copyright 2014 Facebook, Inc. + * Copyright 2017 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,22 +18,26 @@ #error This file may only be included from folly/Uri.h #endif -#include "folly/Conv.h" +#include namespace folly { template 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()) { @@ -46,4 +50,3 @@ String Uri::toString() const { } } // namespace folly -