- 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);