Skip to content

Commit

Permalink
Fixed regex in XPathMatcher to support dots (#4013)
Browse files Browse the repository at this point in the history
  • Loading branch information
kislam01 authored Feb 16, 2024
1 parent f5a0e65 commit 0727b0a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*/
public class XPathMatcher {
// Regular expression to support conditional tags like `plugin[artifactId='maven-compiler-plugin']`
private static final Pattern PATTERN = Pattern.compile("([-\\w]+)\\[([-\\w]+)='([-\\w]+)']");
private static final Pattern PATTERN = Pattern.compile("([-\\w]+)\\[([-\\w]+)='([-\\w.]+)']");
private final String expression;

public XPathMatcher(String expression) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ void matchPom() {
pomXml1)).isTrue();
assertThat(match("/project/build/plugins/plugin[artifactId='maven-compiler-plugin']/configuration/source",
pomXml1)).isTrue();
assertThat(match("/project/build/plugins/plugin[groupId='org.apache.maven.plugins']/configuration/source",
pomXml1)).isTrue();
assertThat(match("/project/build/plugins/plugin[artifactId='somethingElse']/configuration/source",
pomXml1)).isFalse();
assertThat(match("/project/build//plugins/plugin/configuration/source",
Expand Down

0 comments on commit 0727b0a

Please sign in to comment.