This is an automated email from the ASF dual-hosted git repository.
sseifert pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-compiler-java.git
The following commit(s) were added to refs/heads/master by this push:
new 0d774ae SLING-7286 JavaEscapeUtils.makeJavaPackage dows not work with
windows paths
0d774ae is described below
commit 0d774aec2c3addabd1d6e0640542dd758611e2ea
Author: sseifert <[email protected]>
AuthorDate: Mon Dec 4 11:48:49 2017 +0100
SLING-7286 JavaEscapeUtils.makeJavaPackage dows not work with windows paths
---
.../sightly/java/compiler/JavaEscapeUtils.java | 2 +-
.../sightly/java/compiler/JavaEscapeUtilsTest.java | 34 ++++++++++++++++++++++
2 files changed, 35 insertions(+), 1 deletion(-)
diff --git
a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/JavaEscapeUtils.java
b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/JavaEscapeUtils.java
index 08b4669..e22390a 100644
---
a/src/main/java/org/apache/sling/scripting/sightly/java/compiler/JavaEscapeUtils.java
+++
b/src/main/java/org/apache/sling/scripting/sightly/java/compiler/JavaEscapeUtils.java
@@ -135,7 +135,7 @@ public class JavaEscapeUtils {
* @return Java package corresponding to the given scriptName
*/
public static String makeJavaPackage(String scriptName) {
- String classNameComponents[] = StringUtils.split(scriptName, '/');
+ String classNameComponents[] = StringUtils.split(scriptName, "/\\");
StringBuilder legalClassNames = new StringBuilder();
for (int i = 0; i < classNameComponents.length; i++) {
legalClassNames.append(makeJavaIdentifier(classNameComponents[i]));
diff --git
a/src/test/java/org/apache/sling/scripting/sightly/java/compiler/JavaEscapeUtilsTest.java
b/src/test/java/org/apache/sling/scripting/sightly/java/compiler/JavaEscapeUtilsTest.java
new file mode 100644
index 0000000..8766b3d
--- /dev/null
+++
b/src/test/java/org/apache/sling/scripting/sightly/java/compiler/JavaEscapeUtilsTest.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.scripting.sightly.java.compiler;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class JavaEscapeUtilsTest {
+
+ @Test
+ public void testMakeJavaPackage() {
+ assertEquals("apps.projects.script_html",
JavaEscapeUtils.makeJavaPackage("/apps/projects/script.html"));
+ // test also with windows path names
+ assertEquals("apps.projects.script_html",
JavaEscapeUtils.makeJavaPackage("\\apps\\projects\\script.html"));
+ }
+
+}
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].