changeset b4f0e27a3198 in sao:default
details: https://hg.tryton.org/sao?cmd=changeset&node=b4f0e27a3198
description:
        Correctly complete after opening OR-ed parenthesis

        The nested call to replace_ending_clause must be pushed in the result 
instead
        of concatenated because the clause can be OR-ed.
        And pslice must remove depth from the length of the sting.

        issue11477
        review421151003
diffstat:

 src/common.js |  6 +++---
 tests/sao.js  |  1 +
 2 files changed, 4 insertions(+), 3 deletions(-)

diffs (34 lines):

diff -r 8e38c5eebb96 -r b4f0e27a3198 src/common.js
--- a/src/common.js     Thu May 19 21:54:36 2022 +0200
+++ b/src/common.js     Thu May 19 21:58:31 2022 +0200
@@ -1332,7 +1332,7 @@
 
             var pslice = function(string, depth) {
                 if (depth > 0) {
-                    return string.substring(0, depth);
+                    return string.substring(0, string.length - depth);
                 }
                 return string;
             };
@@ -1462,8 +1462,8 @@
                 results.push(domain[i]);
             }
             if (this.is_subdomain(domain[i])) {
-                results = results.concat(this.replace_ending_clause(domain[i],
-                            clause));
+                results.push(
+                    this.replace_ending_clause(domain[i], clause));
             } else {
                 results.push(clause);
             }
diff -r 8e38c5eebb96 -r b4f0e27a3198 tests/sao.js
--- a/tests/sao.js      Thu May 19 21:54:36 2022 +0200
+++ b/tests/sao.js      Thu May 19 21:58:31 2022 +0200
@@ -3051,6 +3051,7 @@
         ['', ["Name: "]],
         [' ', ["", "Name: "]],
         ["Name: foo or", ["Name: foo"]],
+        ['Name: foo (Name: foo or N', ["Name: foo (Name: foo or Name: "]],
         ].forEach(function(test) {
             var value = test[0];
             var expected = test[1];

Reply via email to