You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/01/11 15:11:25 UTC

[camel] branch camel-2.x updated: CAMEL-14372: Fixed file util to not compact http url

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-2.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-2.x by this push:
     new d737119  CAMEL-14372: Fixed file util to not compact http url
d737119 is described below

commit d7371192d6f214431dd79377c67f75ab01f5a4e0
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Jan 11 16:11:02 2020 +0100

    CAMEL-14372: Fixed file util to not compact http url
---
 camel-core/src/main/java/org/apache/camel/util/FileUtil.java     | 6 +++++-
 camel-core/src/test/java/org/apache/camel/util/FileUtilTest.java | 8 ++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/camel-core/src/main/java/org/apache/camel/util/FileUtil.java b/camel-core/src/main/java/org/apache/camel/util/FileUtil.java
index 5bd7270..a6e945f 100644
--- a/camel-core/src/main/java/org/apache/camel/util/FileUtil.java
+++ b/camel-core/src/main/java/org/apache/camel/util/FileUtil.java
@@ -280,13 +280,17 @@ public final class FileUtil {
     }
 
     /**
-     * Compacts a path by stacking it and reducing <tt>..</tt>,
+     * Compacts a file path by stacking it and reducing <tt>..</tt>,
      * and uses the given separator.
      */
     public static String compactPath(String path, String separator) {
         if (path == null) {
             return null;
         }
+
+        if (path.startsWith("http:")) {
+            return path;
+        }
         
         // only normalize if contains a path separator
         if (path.indexOf('/') == -1 && path.indexOf('\\') == -1)  {
diff --git a/camel-core/src/test/java/org/apache/camel/util/FileUtilTest.java b/camel-core/src/test/java/org/apache/camel/util/FileUtilTest.java
index 4b024e3..b29b6f9 100644
--- a/camel-core/src/test/java/org/apache/camel/util/FileUtilTest.java
+++ b/camel-core/src/test/java/org/apache/camel/util/FileUtilTest.java
@@ -272,4 +272,12 @@ public class FileUtilTest extends Assert {
         assertTrue("File not copied", target.exists());
         assertFalse("File not deleted", file.exists());
     }
+
+    @Test
+    public void testCompactHttpPath() {
+        String in = "http://foo.com/apps/func/schemas/part/myap/dummy-schema.xsd";
+        String out = FileUtil.compactPath(in, "/");
+        assertEquals(in, out);
+    }
+
 }