2020-02-05 19:05:49 -08:00
|
|
|
package utils;
|
|
|
|
|
2022-12-08 20:27:51 -06:00
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
2020-02-05 19:05:49 -08:00
|
|
|
|
2023-12-06 11:02:42 +05:30
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
2020-02-05 19:05:49 -08:00
|
|
|
public class SearchUtilTest {
|
2023-12-06 11:02:42 +05:30
|
|
|
@Test
|
|
|
|
public void testEscapeForwardSlash() {
|
|
|
|
// escape "/"
|
2024-09-05 18:42:24 +02:00
|
|
|
assertEquals("\\/foo\\/bar", SearchUtil.escapeForwardSlash("/foo/bar"));
|
2023-12-06 11:02:42 +05:30
|
|
|
// "/" is escaped but "*" is not escaped and is treated as regex. Since currently we want to
|
|
|
|
// retain the regex behaviour with "*"
|
2024-09-05 18:42:24 +02:00
|
|
|
assertEquals("\\/foo\\/bar\\/*", SearchUtil.escapeForwardSlash("/foo/bar/*"));
|
2023-12-06 11:02:42 +05:30
|
|
|
assertEquals("", "");
|
|
|
|
assertEquals("foo", "foo");
|
|
|
|
}
|
2020-02-05 19:05:49 -08:00
|
|
|
}
|