mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-22 06:29:30 +00:00
Themes: Improve RegExp pattern for search.
* The replacement of spaces is now done globally. * The search term is now escaped for RegExp meta characters. props westonruter for the hint. fixes #27479. Built from https://develop.svn.wordpress.org/trunk@27649 git-svn-id: http://core.svn.wordpress.org/trunk@27492 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
18a26bf513
commit
1b2bb74f76
@ -179,11 +179,12 @@ themes.Collection = Backbone.Collection.extend({
|
||||
// Start with a full collection
|
||||
this.reset( themes.data.themes, { silent: true } );
|
||||
|
||||
// The RegExp object to match
|
||||
//
|
||||
// Escape the term string for RegExp meta characters
|
||||
term = term.replace( /[-\/\\^$*+?.()|[\]{}]/g, '\\$&' );
|
||||
|
||||
// Consider spaces as word delimiters and match the whole string
|
||||
// so matching terms can be combined
|
||||
term = term.replace( ' ', ')(?=.*' );
|
||||
term = term.replace( / /g, ')(?=.*' );
|
||||
match = new RegExp( '^(?=.*' + term + ').+', 'i' );
|
||||
|
||||
// Find results
|
||||
|
2
wp-admin/js/theme.min.js
vendored
2
wp-admin/js/theme.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user