You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2013/05/17 02:37:28 UTC

[6/6] git commit: TAP5-2079: Handle incorrect context path properly

TAP5-2079: Handle incorrect context path properly


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/56a11481
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/56a11481
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/56a11481

Branch: refs/heads/master
Commit: 56a1148121577af5f9b18f6604e27fdf4fc21960
Parents: bdfcf9a
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Thu May 16 16:12:21 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu May 16 16:12:21 2013 -0700

----------------------------------------------------------------------
 .../internal/services/PathConstructorImpl.java     |   18 ++++++++++++++-
 .../services/PathConstructorImplSpec.groovy        |    4 ++-
 2 files changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/56a11481/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PathConstructorImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PathConstructorImpl.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PathConstructorImpl.java
index d1e4f1b..9612cf2 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PathConstructorImpl.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PathConstructorImpl.java
@@ -1,3 +1,17 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// Licensed 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.tapestry5.internal.services;
 
 import org.apache.tapestry5.SymbolConstants;
@@ -22,7 +36,9 @@ public class PathConstructorImpl implements PathConstructor
 
         dispatchPrefix = b.toString();
 
-        clientPrefix = contextPath + dispatchPrefix;
+        // If you mis-configure embedded Tomcat, you can get a contextPath of "/" rather than "".
+        // To make things fool proof, we handle that case.
+        clientPrefix = (contextPath.equals("/") ? "" : contextPath) + dispatchPrefix;
     }
 
     public String constructClientPath(String... terms)

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/56a11481/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/PathConstructorImplSpec.groovy
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/PathConstructorImplSpec.groovy b/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/PathConstructorImplSpec.groovy
index 53166cc..466133d 100644
--- a/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/PathConstructorImplSpec.groovy
+++ b/tapestry-core/src/test/groovy/org/apache/tapestry5/internal/services/PathConstructorImplSpec.groovy
@@ -12,7 +12,9 @@ class PathConstructorImplSpec extends Assert {
             ["", "", "/foo/bar", "/foo/bar"],
             ["", "myapp", "/myapp/foo/bar", "/myapp/foo/bar"],
             ["/ctx", "", "/ctx/foo/bar", "/foo/bar"],
-            ["/ctx", "myapp", "/ctx/myapp/foo/bar", "/myapp/foo/bar"]
+            ["/ctx", "myapp", "/ctx/myapp/foo/bar", "/myapp/foo/bar"],
+            // TAP5-2079
+            ["/", "myapp", "/myapp/foo/bar", "/myapp/foo/bar"]
         ] as Object[][]
     }