MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / parseURL

Function parseURL

src/server/api/url_parser.cpp:50–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48{
49
50std::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

Callers 4

HandleRequestMethod · 0.50
testInvalidURLFunction · 0.50
BOOST_AUTO_TEST_CASEFunction · 0.50
LLVMFuzzerTestOneInputFunction · 0.50

Calls 2

countDigitsFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected