| 1382 | } |
| 1383 | |
| 1384 | StringVal StringFunctions::ParseUrl( |
| 1385 | FunctionContext* ctx, const StringVal& url, const StringVal& part) { |
| 1386 | if (url.is_null || part.is_null) return StringVal::null(); |
| 1387 | void* state = ctx->GetFunctionState(FunctionContext::FRAGMENT_LOCAL); |
| 1388 | UrlParser::UrlPart url_part; |
| 1389 | if (state != NULL) { |
| 1390 | url_part = *reinterpret_cast<UrlParser::UrlPart*>(state); |
| 1391 | } else { |
| 1392 | DCHECK(!ctx->IsArgConstant(1)); |
| 1393 | url_part = UrlParser::GetUrlPart(StringValue::FromStringVal(part)); |
| 1394 | } |
| 1395 | |
| 1396 | StringValue result; |
| 1397 | if (!UrlParser::ParseUrl(StringValue::FromStringVal(url), url_part, &result)) { |
| 1398 | // url is malformed, or url_part is invalid. |
| 1399 | if (url_part == UrlParser::INVALID) { |
| 1400 | stringstream ss; |
| 1401 | ss << "Invalid URL part: " << AnyValUtil::ToString(part); |
| 1402 | ctx->AddWarning(ss.str().c_str()); |
| 1403 | } else { |
| 1404 | stringstream ss; |
| 1405 | ss << "Could not parse URL: " << AnyValUtil::ToString(url); |
| 1406 | ctx->AddWarning(ss.str().c_str()); |
| 1407 | } |
| 1408 | return StringVal::null(); |
| 1409 | } |
| 1410 | StringVal result_sv; |
| 1411 | result.ToStringVal(&result_sv); |
| 1412 | return result_sv; |
| 1413 | } |
| 1414 | |
| 1415 | void StringFunctions::ParseUrlClose( |
| 1416 | FunctionContext* ctx, FunctionContext::FunctionStateScope scope) { |
nothing calls this directly
no test coverage detected