Skip to content

Commit

Permalink
fix(search): Search not returning result if query text contains forwa…
Browse files Browse the repository at this point in the history
…rd slash (datahub-project#10932)

Co-authored-by: si-chakraborty <[email protected]>
Co-authored-by: david-leifker <[email protected]>
  • Loading branch information
3 people authored Sep 5, 2024
1 parent 59f9a4b commit 35d134b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
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 @@ -70,7 +70,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

0 comments on commit 35d134b

Please sign in to comment.