| 48 | { |
| 49 | |
| 50 | std::optional<ParsedURL> parseURL(std::string::iterator &iter, const std::string::iterator end) |
| 51 | { |
| 52 | ParsedURL out; |
| 53 | |
| 54 | try |
| 55 | { |
| 56 | const auto ok = x3::parse(iter, end, url_parser, out); |
| 57 | |
| 58 | if (ok && iter == end) |
| 59 | { |
| 60 | // prefix = /{service}/v{version}/{profile}/ |
| 61 | out.prefix_length = |
| 62 | 1 + out.service.size() + 2 + countDigits(out.version) + 1 + out.profile.size() + 1; |
| 63 | return std::make_optional(out); |
| 64 | } |
| 65 | } |
| 66 | catch (const x3::expectation_failure<std::string::iterator> &failure) |
| 67 | { |
| 68 | // The grammar above using expectation parsers ">" does not automatically increment the |
| 69 | // iterator to the failing position. Extract the position from the exception ourselves. |
| 70 | iter = failure.where(); |
| 71 | } |
| 72 | |
| 73 | return std::nullopt; |
| 74 | } |
| 75 | |
| 76 | } // namespace osrm::server::api |
no test coverage detected