X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FUri-inl.h;h=812c400a7960dc4803127ba342fb4a7242598739;hb=398f83735ae9c087774af4894a794510a1e375c0;hp=71a23cbbda6ebd413426d718fdeffa427ea1fb6b;hpb=9ff69037a4faab0ffb5e781b993428cceef62c9b;p=folly.git diff --git a/folly/Uri-inl.h b/folly/Uri-inl.h index 71a23cbb..812c400a 100644 --- a/folly/Uri-inl.h +++ b/folly/Uri-inl.h @@ -1,5 +1,5 @@ /* - * Copyright 2013 Facebook, Inc. + * Copyright 2015 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 -