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

Method parseProxyConfig

src/extension/extension.cpp:211–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209}
210
211std::optional<ExtensionProxyConfig> ExtensionUtils::parseProxyConfig(const std::string& proxyURL) {
212 auto parsedURL = parseURL(proxyURL);
213 if (parsedURL.host.empty()) {
214 return std::nullopt;
215 }
216 ExtensionProxyConfig config{parsedURL.host, parsedURL.port == -1 ? 80 : parsedURL.port, "", ""};
217 auto authority = proxyURL;
218 auto schemeEnd = authority.find("://");
219 if (schemeEnd != std::string::npos) {
220 authority = authority.substr(schemeEnd + 3);
221 }
222 auto pathStart = authority.find_first_of("/?#");
223 if (pathStart != std::string::npos) {
224 authority = authority.substr(0, pathStart);
225 }
226 auto atPos = authority.rfind('@');
227 if (atPos != std::string::npos) {
228 auto userInfo = authority.substr(0, atPos);
229 auto passwordPos = userInfo.find(':');
230 if (passwordPos == std::string::npos) {
231 config.username = userInfo;
232 } else {
233 config.username = userInfo.substr(0, passwordPos);
234 config.password = userInfo.substr(passwordPos + 1);
235 }
236 }
237 return config;
238}
239
240std::optional<ExtensionProxyConfig> ExtensionUtils::getProxyConfigForURL(const std::string& url) {
241 auto targetURL = parseURL(url);

Callers

nothing calls this directly

Calls 3

parseURLFunction · 0.85
emptyMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected