Append an HTTP rel-path to a local filesystem path. The returned path is normalized for the platform.
| 70 | // Append an HTTP rel-path to a local filesystem path. |
| 71 | // The returned path is normalized for the platform. |
| 72 | std::string |
| 73 | path_cat( |
| 74 | beast::string_view base, |
| 75 | beast::string_view path) |
| 76 | { |
| 77 | if (base.empty()) |
| 78 | return std::string(path); |
| 79 | std::string result(base); |
| 80 | #ifdef BOOST_MSVC |
| 81 | char constexpr path_separator = '\\'; |
| 82 | if(result.back() == path_separator) |
| 83 | result.resize(result.size() - 1); |
| 84 | result.append(path.data(), path.size()); |
| 85 | for(auto& c : result) |
| 86 | if(c == '/') |
| 87 | c = path_separator; |
| 88 | #else |
| 89 | char constexpr path_separator = '/'; |
| 90 | if(result.back() == path_separator) |
| 91 | result.resize(result.size() - 1); |
| 92 | result.append(path.data(), path.size()); |
| 93 | #endif |
| 94 | return result; |
| 95 | } |
| 96 | |
| 97 | // Return a response for the given request. |
| 98 | // |
no test coverage detected