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:25 UTC

[3/6] git commit: Use a single RE to detect absolute paths and paths starting with a scheme

Use a single RE to detect absolute paths and paths starting with a scheme


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

Branch: refs/heads/master
Commit: 2bb0cd29aae5cea4a32ecb8a2754836bf12924cd
Parents: 9d61731
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Thu May 16 15:42:39 2013 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Thu May 16 15:42:39 2013 -0700

----------------------------------------------------------------------
 .../internal/services/assets/CSSURLRewriter.java   |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/2bb0cd29/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/CSSURLRewriter.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/CSSURLRewriter.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/CSSURLRewriter.java
index ed9d12d..149ae74 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/CSSURLRewriter.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/assets/CSSURLRewriter.java
@@ -47,7 +47,8 @@ public class CSSURLRewriter extends DelegatingSRS
     // Group 3 is any query parmameters (see issue TAP5-2106)
     private final Pattern urlPattern = Pattern.compile("url\\(\\s*(['\"]?)(.+?)(\\?.*)?\\1\\s*\\)", Pattern.MULTILINE);
 
-    private final Pattern urlPrefixPattern = Pattern.compile("^\\p{Alpha}\\w*:");
+    // Does it start with a '/' or what looks like a scheme ("http:")?
+    private final Pattern completeURLPattern = Pattern.compile("^/|(\\p{Alpha}\\w*:)");
 
     private final OperationTracker tracker;
 
@@ -127,7 +128,7 @@ public class CSSURLRewriter extends DelegatingSRS
 
             // When the URL starts with a slash, there's no need to rewrite it (this is actually rare in Tapestry
             // as you want to use relative URLs to leverage the asset pipeline.
-            if (url.startsWith("/") || urlPrefixPattern.matcher(url).find())
+            if (completeURLPattern.matcher(url).find())
             {
                 // This may normalize single quotes, or missing quotes, to double quotes, but is not
                 // considered a real change, since all such variations are valid.