Skip to content

Commit

Permalink
TermInput.js: Encode and quote terms, not the other way round
Browse files Browse the repository at this point in the history
Any separator which needs to be encoded, won't be detected
and thus no unnecessary quoting happens. If, on the other
hand, the quoting is necessary due to an unencoded separator,
the quotes are not encoded, as the server doesn't expect or
need this.
  • Loading branch information
nilmerg committed Aug 1, 2023
1 parent 9ff9037 commit 975d262
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions asset/js/widget/TermInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,15 @@ define(["../notjQuery", "BaseInput"], function ($, BaseInput) {
termsToQueryString(terms) {
let quoted = [];
for (const termData of terms) {
if (termData.search.indexOf(this.separator) >= 0) {
quoted.push({ ...termData, search: '"' + termData.search + '"' });
} else {
quoted.push(termData);
let search = this.encodeTerm(termData).search;
if (search.indexOf(this.separator) >= 0) {
search = '"' + termData.search + '"';
}

quoted.push(search);
}

return super.termsToQueryString(quoted);
return quoted.join(this.separator).trim();
}

complete(input, data) {
Expand Down

0 comments on commit 975d262

Please sign in to comment.