Filter does not work when space at start or end

Created on 20 November 2015, over 9 years ago
Updated 23 April 2025, 9 days ago

This line of the JS removes any outside whitespace:

searchString = searchString.replace(/^\s+|\s+$/, '');

However, that comes after these two lines:

  var db = this;
  this.searchString = searchString;

If you include a space, it correctly strips out the outside whitespace and then runs the search and gets the results. But, upon display of the results, this check is evaluated:

          // Verify if these are still the matches the user wants to see.
          if (db.searchString == searchString) {

As currently defined, the user input and db.searchString is "word " (with a space) and the search that was submitted was just "word" (without a space). So in this If db.searchString and searchString do not match. In other words, "word " is submitted, the space is stripped and the AJAX does a query or cache call for "word", but then after all that does not display the result.

My solution was to make line 12, where the outside whitespace is stripped, as follows:

this.searchString = searchString = searchString.replace(/^\s+|\s+$/, '');

In this way, the whitespace is trimmed and the search (minus whitespace) is displayed to the user.

πŸ› Bug report
Status

Closed: outdated

Version

1.2

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States dandaman

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡·πŸ‡΄Romania vasike Ramnicu Valcea

    As Drupal 7.x and also modules 7.x versions "ended their lives", closing the 7.x issues.

    And thanks for participating and using the module.

    p.s. if this still an issue on the latest 2.x version, please feel free to re-open and update the version accordingly.

Production build 0.71.5 2024