5 * Checks if a string contains a value. The comparison value can be a string or
8 * Any strings starting and ending with `/` are ignored. Use the
9 * matchesStringOrRegExp() util to match regexes.
11 module.exports = function containsString(
13 comparison /*: string | Array<string>*/
14 ) /*: false | { match: string, pattern: string }*/ {
15 if (!Array.isArray(comparison)) {
16 return testAgainstString(input, comparison);
19 for (const comparisonItem of comparison) {
20 const testResult = testAgainstString(input, comparisonItem);
28 function testAgainstString(value, comparison) {
29 if (!comparison) return false;
30 if (comparison[0] === "/" && comparison[comparison.length - 1] === "/") {
34 if (value.indexOf(comparison) >= 0) {
35 return { match: value, pattern: comparison };