Differential D16886 Diff 40655 webroot/rsrc/externals/javelin/lib/control/typeahead/normalizer/TypeaheadNormalizer.js
Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/externals/javelin/lib/control/typeahead/normalizer/TypeaheadNormalizer.js
Show All 12 Lines | statics : { | ||||
* @param string | * @param string | ||||
* @return string Normalized string. | * @return string Normalized string. | ||||
*/ | */ | ||||
normalize : function(str) { | normalize : function(str) { | ||||
// NOTE: We specifically normalize "(" and ")" into spaces so that | // NOTE: We specifically normalize "(" and ")" into spaces so that | ||||
// we can match tokenizer functions like "members(project)". | // we can match tokenizer functions like "members(project)". | ||||
// NOTE: We specifically do NOT normalize "\n" because it is used as | |||||
// a delimiter between components of typeahead result names, like the | |||||
// name of a project and its tags. | |||||
return ('' + str) | return ('' + str) | ||||
.toLocaleLowerCase() | .toLocaleLowerCase() | ||||
.replace(/[\.,\/#!$%\^&\*;:{}=_`~]/g, '') | .replace(/[\.,\/#!$%\^&\*;:{}=_`~]/g, '') | ||||
.replace(/[-\[\]\(\)]/g, ' ') | .replace(/[-\[\]\(\)]/g, ' ') | ||||
.replace(/ +/g, ' ') | .replace(/ +/g, ' ') | ||||
.replace(/^\s*|\s*$/g, ''); | .replace(/^\s*|\s*$/g, ''); | ||||
} | } | ||||
} | } | ||||
}); | }); |