Append an HTTP rel-path to a local filesystem path. The returned path is normalized for the platform.
| 53 | // Append an HTTP rel-path to a local filesystem path. |
| 54 | // The returned path is normalized for the platform. |
| 55 | std::string |
| 56 | path_cat( |
| 57 | beast::string_view base, |
| 58 | beast::string_view path) |
| 59 | { |
| 60 | if(base.empty()) |
| 61 | return std::string(path); |
| 62 | std::string result(base); |
| 63 | #ifdef BOOST_MSVC |
| 64 | char constexpr path_separator = '\\'; |
| 65 | if(result.back() == path_separator) |
| 66 | result.resize(result.size() - 1); |
| 67 | result.append(path.data(), path.size()); |
| 68 | for(auto& c : result) |
| 69 | if(c == '/') |
| 70 | c = path_separator; |
| 71 | #else |
| 72 | char constexpr path_separator = '/'; |
| 73 | if(result.back() == path_separator) |
| 74 | result.resize(result.size() - 1); |
| 75 | result.append(path.data(), path.size()); |
| 76 | #endif |
| 77 | return result; |
| 78 | } |
| 79 | |
| 80 | // Return a response for the given request. |
| 81 | // |
no test coverage detected