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 2014/09/29 08:32:26 UTC

[4/4] git commit: Case when uri has fragment and does not have query

Case when uri has fragment and does not have query


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/383cce53
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/383cce53
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/383cce53

Branch: refs/heads/camel-2.12.x
Commit: 383cce5364ba209a97bf7b554d9e51d6a31bbf9d
Parents: daeb559
Author: Vitaly Lavrov <la...@osinka.ru>
Authored: Mon Sep 8 21:11:02 2014 +0400
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Sep 29 08:32:14 2014 +0200

----------------------------------------------------------------------
 .../src/main/java/org/apache/camel/util/URISupport.java       | 3 +++
 .../src/test/java/org/apache/camel/util/URISupportTest.java   | 7 +++++++
 2 files changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/383cce53/camel-core/src/main/java/org/apache/camel/util/URISupport.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/URISupport.java b/camel-core/src/main/java/org/apache/camel/util/URISupport.java
index 0f37a2c..607f859 100644
--- a/camel-core/src/main/java/org/apache/camel/util/URISupport.java
+++ b/camel-core/src/main/java/org/apache/camel/util/URISupport.java
@@ -321,6 +321,9 @@ public final class URISupport {
         // assemble string as new uri and replace parameters with the query instead
         String s = uri.toString();
         String before = ObjectHelper.before(s, "?");
+        if (before == null) {
+            before = ObjectHelper.before(s, "#");
+        }
         if (before != null) {
             s = before;
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/383cce53/camel-core/src/test/java/org/apache/camel/util/URISupportTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/util/URISupportTest.java b/camel-core/src/test/java/org/apache/camel/util/URISupportTest.java
index 0e6f1b1..cdefcec 100644
--- a/camel-core/src/test/java/org/apache/camel/util/URISupportTest.java
+++ b/camel-core/src/test/java/org/apache/camel/util/URISupportTest.java
@@ -155,6 +155,13 @@ public class URISupportTest extends ContextTestSupport {
         assertEquals("smtp://localhost#fragmentOne", resultUri.toString());
     }
 
+    public void testCreateURIWithQueryHasOneFragmentAndQueryParameter() throws Exception {
+        URI uri = new URI("smtp://localhost#fragmentOne");
+        URI resultUri = URISupport.createURIWithQuery(uri, "utm_campaign=launch");
+        assertNotNull(resultUri);
+        assertEquals("smtp://localhost?utm_campaign=launch#fragmentOne", resultUri.toString());
+    }
+
     public void testNormalizeEndpointWithEqualSignInParameter() throws Exception {
         String out = URISupport.normalizeUri("jms:queue:foo?selector=somekey='somevalue'&foo=bar");
         assertNotNull(out);