```js
var q = term.replace(/^\s+|\s+$/g, "").replace(/'/g, '\\\'').toLowerCase();
    qp = "'Resource Name' CONTAINS IGNORING CASE '",
    qs = "'";

if (q === '') return '';
return qp + q + qs;
```

Prevent SQL injection (at least naïvely) and as a bonus, trim so the `if (q === '')` works.