| 36 | namespace internal { |
| 37 | |
| 38 | string JoinPathImpl(std::initializer_list<StringPiece> paths) { |
| 39 | string result; |
| 40 | |
| 41 | for (StringPiece path : paths) { |
| 42 | if (path.empty()) continue; |
| 43 | |
| 44 | if (result.empty()) { |
| 45 | result = string(path); |
| 46 | continue; |
| 47 | } |
| 48 | |
| 49 | if (result[result.size() - 1] == '/') { |
| 50 | if (IsAbsolutePath(path)) { |
| 51 | strings::StrAppend(&result, path.substr(1)); |
| 52 | } else { |
| 53 | strings::StrAppend(&result, path); |
| 54 | } |
| 55 | } else { |
| 56 | if (IsAbsolutePath(path)) { |
| 57 | strings::StrAppend(&result, path); |
| 58 | } else { |
| 59 | strings::StrAppend(&result, "/", path); |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | return result; |
| 65 | } |
| 66 | |
| 67 | // Return the parts of the URI, split on the final "/" in the path. If there is |
| 68 | // no "/" in the path, the first part of the output is the scheme and host, and |
no test coverage detected