| 1362 | } |
| 1363 | |
| 1364 | void StringFunctions::ParseUrlPrepare( |
| 1365 | FunctionContext* ctx, FunctionContext::FunctionStateScope scope) { |
| 1366 | if (scope != FunctionContext::FRAGMENT_LOCAL) return; |
| 1367 | if (!ctx->IsArgConstant(1)) return; |
| 1368 | DCHECK_EQ(ctx->GetArgType(1)->type, FunctionContext::TYPE_STRING); |
| 1369 | StringVal* part = reinterpret_cast<StringVal*>(ctx->GetConstantArg(1)); |
| 1370 | if (part->is_null) return; |
| 1371 | auto url_part = make_unique<UrlParser::UrlPart>( |
| 1372 | UrlParser::GetUrlPart(StringValue::FromStringVal(*part))); |
| 1373 | if (*url_part == UrlParser::INVALID) { |
| 1374 | stringstream ss; |
| 1375 | ss << "Invalid URL part: " << AnyValUtil::ToString(*part) << endl |
| 1376 | << "(Valid URL parts are 'PROTOCOL', 'HOST', 'PATH', 'REF', 'AUTHORITY', 'FILE', " |
| 1377 | << "'USERINFO', and 'QUERY')"; |
| 1378 | ctx->SetError(ss.str().c_str()); |
| 1379 | return; |
| 1380 | } |
| 1381 | ctx->SetFunctionState(scope, url_part.release()); |
| 1382 | } |
| 1383 | |
| 1384 | StringVal StringFunctions::ParseUrl( |
| 1385 | FunctionContext* ctx, const StringVal& url, const StringVal& part) { |
nothing calls this directly
no test coverage detected