Skip to content

Commit

Permalink
Fix the regex that identifies if the item is search term for autocomp…
Browse files Browse the repository at this point in the history
…lete

All digital items that may or may not have type prefixes(like "asset:") are
existing values, the rest are search terms.

When we switched to LinkTargets autocomplete in 6d0b00e, we updated the
regex to handle non-ticket link types like "asset", "articles", etc. The
regex wasn't correct as it treated "foo" in "foo bar" as an existing value,
thus if you selected the ticket from dropdown, the input would be like "foo
123" instead of "123".
  • Loading branch information
sunnavy committed Feb 27, 2024
1 parent cf34cad commit e489e34
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion share/static/js/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ window.RT.Autocomplete.bind = function(from) {
// remove non-integers in case subject search with spaces in (like "foo bar")
var new_terms = [];
for ( var i = 0; i < terms.length; i++ ) {
if ( terms[i].match(/^(?:(asset|a|group|user):)\D/) ) {
if ( !terms[i].match(/^(?:(asset|a|group|user):)?\d+$/) ) {
break; // Items after the first non-integers are all parts of search string
}
new_terms.push(terms[i]);
Expand Down

0 comments on commit e489e34

Please sign in to comment.