Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Delete unused string util from metabase lib (#64389)

Nemanja Glumac0af38ef8f021
diff --git a/frontend/src/metabase/lib/string.js b/frontend/src/metabase/lib/string.js
deleted file mode 100644
index 2e335ae1fbe..00000000000
--- a/frontend/src/metabase/lib/string.js
+++ /dev/null
@@ -1,23 +0,0 @@
-import _ from "underscore";
-
-// Creates a regex that will find an order dependent, case insensitive substring. All whitespace will be rendered as ".*" in the regex, to create a fuzzy search.
-export function createMultiwordSearchRegex(input) {
- if (input) {
- return new RegExp(_.map(input.split(/\s+/), regexpEscape).join(".*"), "i");
- }
-}
-
-// prefix special characters with "\" for creating a regex
-export function regexpEscape(s) {
- const regexpSpecialChars = /[\^\$\\\.\*\+\?\(\)\[\]\{\}\|]/g;
- // "$&" in the replacement string is replaced with the matched string
- return s.replace(regexpSpecialChars, "\\$&");
-}
-
-export function caseInsensitiveSearch(haystack, needle) {
- return (
- !needle ||
- (haystack != null &&
- haystack.toLowerCase().indexOf(needle.toLowerCase()) >= 0)
- );
-}
diff --git a/frontend/test/metabase/lib/string.unit.spec.js b/frontend/test/metabase/lib/string.unit.spec.js
deleted file mode 100644
index 6632e327d42..00000000000
--- a/frontend/test/metabase/lib/string.unit.spec.js
+++ /dev/null
@@ -1,17 +0,0 @@
-import { regexpEscape } from "metabase/lib/string";
-
-describe("regexpEscape", () => {
- const testCases = [
- ["nothing special here", "nothing special here"],
- ["somewhat ./\\ special", "somewhat \\./\\\\ special"],
- [
- "extra special ^$\\.*+?()[]{}|",
- "extra special \\^\\$\\\\\\.\\*\\+\\?\\(\\)\\[\\]\\{\\}\\|",
- ],
- ];
- for (const [raw, escaped] of testCases) {
- it(`should escape "${raw}" to "${escaped}"`, () => {
- expect(regexpEscape(raw)).toEqual(escaped);
- });
- }
-});