MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / parseURL

Function parseURL

src/extension/extension.cpp:58–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58ParsedURL parseURL(std::string url) {
59 ParsedURL result;
60 auto schemeEnd = url.find("://");
61 if (schemeEnd != std::string::npos) {
62 result.scheme = common::StringUtils::getLower(url.substr(0, schemeEnd));
63 url = url.substr(schemeEnd + 3);
64 }
65 auto pathStart = url.find_first_of("/?#");
66 if (pathStart != std::string::npos) {
67 url = url.substr(0, pathStart);
68 }
69 auto atPos = url.rfind('@');
70 if (atPos != std::string::npos) {
71 url = url.substr(atPos + 1);
72 }
73 if (url.starts_with('[')) {
74 auto bracketEnd = url.find(']');
75 if (bracketEnd != std::string::npos) {
76 result.host = url.substr(1, bracketEnd - 1);
77 if (bracketEnd + 1 < url.size() && url[bracketEnd + 1] == ':') {
78 result.port = parsePort(url.substr(bracketEnd + 2));
79 }
80 }
81 return result;
82 }
83 auto portPos = url.rfind(':');
84 if (portPos != std::string::npos && url.find(':') == portPos) {
85 result.host = url.substr(0, portPos);
86 result.port = parsePort(url.substr(portPos + 1));
87 } else {
88 result.host = url;
89 }
90 return result;
91}
92
93bool noProxyMatches(std::string noProxy, const ParsedURL& target) {
94 auto targetHost = common::StringUtils::getLower(target.host);

Callers 4

noProxyMatchesFunction · 0.85
getExtensionRepoInfoFunction · 0.85
parseProxyConfigMethod · 0.85
getProxyConfigForURLMethod · 0.85

Calls 3

parsePortFunction · 0.85
findMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected