Skip to content

Commit 7f84024

Browse files
authored
Merge bce128f into 78dddf8
2 parents 78dddf8 + bce128f commit 7f84024

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/main/net-placeholders/MatchesRegexPlaceholderHandler.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ the License. You may obtain a copy of the License at
1111
See the License for the specific language governing permissions and
1212
limitations under the License.
1313
*/
14+
using System;
1415
using System.Text.RegularExpressions;
1516
using Org.XmlUnit.Diff;
1617

@@ -30,12 +31,17 @@ public class MatchesRegexPlaceholderHandler : IPlaceholderHandler {
3031
public string Keyword { get { return PLACEHOLDER_NAME; } }
3132
/// <inheritdoc/>
3233
public ComparisonResult Evaluate(string testText, params string[] args) {
33-
if (args.Length > 0 && args[0] != null && args[0] != "") {
34-
var pattern = new Regex(args[0].Trim());
35-
if (testText != null && Evaluate(testText.Trim(), pattern)) {
36-
return ComparisonResult.EQUAL;
34+
if (args.Length > 0 && !string.IsNullOrEmpty(args[0])) {
35+
try {
36+
var pattern = new Regex(args[0].Trim());
37+
if (testText != null && Evaluate(testText.Trim(), pattern)) {
38+
return ComparisonResult.EQUAL;
39+
}
40+
} catch(ArgumentException e) {
41+
throw new XMLUnitException(e.Message, e);
3742
}
3843
}
44+
3945
return ComparisonResult.DIFFERENT;
4046
}
4147

0 commit comments

Comments
 (0)