Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(search): Search not returning result if query text contains forward slash #10932

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datahub-frontend/app/utils/SearchUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private SearchUtil() {
@Nonnull
public static String escapeForwardSlash(@Nonnull String input) {
if (input.contains("/")) {
input = input.replace("/", "\\\\/");
input = input.replace("/", "\\/");
}
return input;
}
Expand Down
4 changes: 2 additions & 2 deletions datahub-frontend/test/utils/SearchUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ public class SearchUtilTest {
@Test
public void testEscapeForwardSlash() {
// escape "/"
assertEquals("\\\\/foo\\\\/bar", SearchUtil.escapeForwardSlash("/foo/bar"));
assertEquals("\\/foo\\/bar", SearchUtil.escapeForwardSlash("/foo/bar"));
// "/" is escaped but "*" is not escaped and is treated as regex. Since currently we want to
// retain the regex behaviour with "*"
assertEquals("\\\\/foo\\\\/bar\\\\/*", SearchUtil.escapeForwardSlash("/foo/bar/*"));
assertEquals("\\/foo\\/bar\\/*", SearchUtil.escapeForwardSlash("/foo/bar/*"));
assertEquals("", "");
assertEquals("foo", "foo");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static <T> T bindArgument(Object argument, Class<T> clazz) {
@Nonnull
public static String escapeForwardSlash(@Nonnull String input) {
if (input.contains("/")) {
input = input.replace("/", "\\\\/");
input = input.replace("/", "\\/");
}
return input;
}
Expand Down
Loading