Skip to content

Commit

Permalink
Unescape url after extracting parameters (facebookincubator#10185)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebookincubator#10185

Updating the url_extract_parameter Presto UDF to unescape results, this is to match the existing behavior in Presto Java.

Reviewed By: kevinwilfong

Differential Revision: D58559892

fbshipit-source-id: 61818b377382f1da104f7e074620b7dc8ad0b305
  • Loading branch information
Daniel Jonathan Hunte authored and facebook-github-bot committed Jun 14, 2024
1 parent 194772c commit 3ac08d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion velox/functions/prestosql/URLFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ struct UrlExtractParameterFunction {
auto key = detail::submatch((*it), 2);
if (param.compare(key) == 0) {
auto value = detail::submatch((*it), 3);
result.setNoCopy(value);
detail::urlUnescape(result, value);
return true;
}
}
Expand Down
4 changes: 4 additions & 0 deletions velox/functions/prestosql/tests/URLFunctionsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ TEST_F(URLFunctionsTest, extractParameter) {
extractParam(
"http://example.com/path1/p.php?k1=v1&k2=v2&k3&k4#Ref1", "k1"),
"v1");
// Tests unescaping functionality.
EXPECT_EQ(
extractParam("http://example.com/path1/p.php?k1=v1%2Bv2#Ref1", "k1"),
"v1+v2");
EXPECT_EQ(
extractParam(
"http://example.com/path1/p.php?k1=v1&k2=v2&k3&k4#Ref1", "k3"),
Expand Down

0 comments on commit 3ac08d5

Please sign in to comment.