File tree Expand file tree Collapse file tree
src/main/net-placeholders Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ;
1415using System . Text . RegularExpressions ;
1516using 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
You can’t perform that action at this time.
0 commit comments