camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject git commit: Case when uri has fragment and does not have query
Date Mon, 29 Sep 2014 06:32:42 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.13.x 229890c49 -> 66803bcc6


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/66803bcc
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/66803bcc
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/66803bcc

Branch: refs/heads/camel-2.13.x
Commit: 66803bcc6e0c789a0f309bc769daf520a6e2ec91
Parents: 229890c
Author: Vitaly Lavrov <lavrov@osinka.ru>
Authored: Mon Sep 8 21:11:02 2014 +0400
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Sep 29 08:32:37 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/66803bcc/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/66803bcc/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);


Mime
View raw message