You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 10:00:09 UTC
[sling-org-apache-sling-resourceresolver] 39/47: SLING-2639 -
adding check for extension in resource names with vanity paths
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.resourceresolver-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git
commit 0770ac00940a7b2cb7973739b95419101383f9c0
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Tue Oct 30 16:36:04 2012 +0000
SLING-2639 - adding check for extension in resource names with vanity paths
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/resourceresolver@1403772 13f79535-47bb-0310-9956-ffa450edef68
---
.../resourceresolver/impl/mapping/MapEntries.java | 27 ++++++++++++++++------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
index b7015f1..098a2b5 100644
--- a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
+++ b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java
@@ -560,12 +560,14 @@ public class MapEntries implements EventHandler {
// sling:vanityPath
// property (or its parent if the node is called
// jcr:content)
- final String redirect;
+ final Resource redirectTarget;
if (resource.getName().equals("jcr:content")) {
- redirect = resource.getParent().getPath();
+ redirectTarget = resource.getParent();
} else {
- redirect = resource.getPath();
+ redirectTarget = resource;
}
+ final String redirect = redirectTarget.getPath();
+ final String redirectName = redirectTarget.getName();
// whether the target is attained by a 302/FOUND or by an
// internal redirect is defined by the sling:redirect
@@ -575,12 +577,23 @@ public class MapEntries implements EventHandler {
: -1;
final String checkPath = result[1];
- // 1. entry with exact match
- this.addEntry(entryMap, checkPath, new MapEntry(url + "$", status, false, redirect + ".html"));
- // 2. entry with match supporting selectors and extension
- this.addEntry(entryMap, checkPath, new MapEntry(url + "(\\..*)", status, false, redirect + "$1"));
+ if (redirectName.indexOf('.') > -1) {
+ // 1. entry with exact match
+ this.addEntry(entryMap, checkPath, new MapEntry(url + "$", status, false, redirect));
+ final int idx = redirectName.lastIndexOf('.');
+ final String extension = redirectName.substring(idx + 1);
+
+ // 2. entry with extension
+ this.addEntry(entryMap, checkPath, new MapEntry(url + "\\." + extension, status, false, redirect));
+ } else {
+ // 1. entry with exact match
+ this.addEntry(entryMap, checkPath, new MapEntry(url + "$", status, false, redirect + ".html"));
+
+ // 2. entry with match supporting selectors and extension
+ this.addEntry(entryMap, checkPath, new MapEntry(url + "(\\..*)", status, false, redirect + "$1"));
+ }
// 3. keep the path to return
targetPaths.add(redirect);
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.