diff --git a/src/common.js b/src/common.js index c4babd9bee..f6973f45fe 100644 --- a/src/common.js +++ b/src/common.js @@ -1282,7 +1282,7 @@ var pslice = function(string, depth) { if (depth > 0) { - return string.substring(0, depth); + return string.substring(0, string.length - depth); } return string; }; @@ -1415,8 +1415,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 --git a/tests/sao.js b/tests/sao.js index c4e3c5a5ee..a1ec179f4c 100644 --- a/tests/sao.js +++ b/tests/sao.js @@ -2993,6 +2993,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];