You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:56:55 UTC
[sling-org-apache-sling-pipes] 11/31: SLING-5729 pipe expressions
should allow regexp with {n} or {n, m} (patch provided by Nicolas Peltier)
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.pipes-0.0.10
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-pipes.git
commit 96b39895e93d27db24a814ace55998e051c858da
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Tue Jun 21 15:57:18 2016 +0000
SLING-5729 pipe expressions should allow regexp with {n} or {n,m} (patch provided by Nicolas Peltier)
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/sling-pipes@1749563 13f79535-47bb-0310-9956-ffa450edef68
---
src/main/java/org/apache/sling/pipes/PipeBindings.java | 2 +-
src/test/java/org/apache/sling/pipes/PipeBindingsTest.java | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/apache/sling/pipes/PipeBindings.java b/src/main/java/org/apache/sling/pipes/PipeBindings.java
index 0331d48..c1f9f62 100644
--- a/src/main/java/org/apache/sling/pipes/PipeBindings.java
+++ b/src/main/java/org/apache/sling/pipes/PipeBindings.java
@@ -60,7 +60,7 @@ public class PipeBindings {
Map<String, Resource> outputResources = new HashMap<>();
- private static final Pattern INJECTED_SCRIPT = Pattern.compile("\\$\\{([^\\}]*)\\}");
+ private static final Pattern INJECTED_SCRIPT = Pattern.compile("\\$\\{(([^\\{^\\}]*(\\{[0-9,]+\\})?)*)\\}");
/**
* public constructor
diff --git a/src/test/java/org/apache/sling/pipes/PipeBindingsTest.java b/src/test/java/org/apache/sling/pipes/PipeBindingsTest.java
index 78858cc..7423c65 100644
--- a/src/test/java/org/apache/sling/pipes/PipeBindingsTest.java
+++ b/src/test/java/org/apache/sling/pipes/PipeBindingsTest.java
@@ -64,6 +64,8 @@ public class PipeBindingsTest extends AbstractPipeTest {
expressions.put("blah ${blah}", "'blah ' + blah");
expressions.put("${blah}${blah}", "blah + '' + blah");
expressions.put("+[${blah}]", "'+[' + blah + ']'");
+ expressions.put("${(new Regexp('.{3}').test(path)}","(new Regexp('.{3}').test(path)");
+ expressions.put("${(new Regexp('.{3,5}').test(path)}","(new Regexp('.{3,5}').test(path)");
for (Map.Entry<String,String> test : expressions.entrySet()){
assertEquals(test.getKey() + " should be transformed in " + test.getValue(), test.getValue(), bindings.computeECMA5Expression(test.getKey()));
}
@@ -119,4 +121,4 @@ public class PipeBindingsTest extends AbstractPipeTest {
Number expression = (Number)bindings.instantiateObject("${testSumFunction(1,2)}");
assertEquals("computed expression have testSum script's functionavailable", 3, expression.intValue());
}
-}
+}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.