MCPcopy Create free account
hub / github.com/dartsim/dart / fromStringOrPath

Method fromStringOrPath

dart/common/Uri.cpp:256–284  ·  view source on GitHub ↗

==============================================================================

Source from the content-addressed store, hash-verified

254
255//==============================================================================
256bool Uri::fromStringOrPath(const std::string& _input)
257{
258 // TODO(JS): Need to check if _input is an "absolute" path?
259
260#ifdef _WIN32
261
262 // Assume that any URI begin with pattern [SINGLE_LETTER]:[/ or \\] is an
263 // absolute path.
264 static std::regex windowsPathRegex(R"END([a-zA-Z]:[/|\\])END");
265 const bool isPath = std::regex_search(
266 _input, windowsPathRegex, std::regex_constants::match_continuous);
267
268 if (isPath)
269 return fromPath(_input);
270
271#else
272
273 // Assume that any URI without a scheme is a path.
274 static std::regex uriSchemeRegex(R"END(^(([^:/?#]+):))END");
275 const bool noScheme = !std::regex_search(
276 _input, uriSchemeRegex, std::regex_constants::match_continuous);
277
278 if (noScheme)
279 return fromPath(_input);
280
281#endif
282
283 return fromString(_input);
284}
285
286//==============================================================================
287bool Uri::fromRelativeUri(

Callers 4

getUriMethod · 0.80
UriFunction · 0.80
TESTFunction · 0.80

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.64