[jira] [Commented] (SLING-11352) Cannot create path-only mapping rule in /etc/map

2022-09-26 Thread Csaba Varga (Jira)


[ 
https://issues.apache.org/jira/browse/SLING-11352?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17609444#comment-17609444
 ] 

Csaba Varga commented on SLING-11352:
-

I have opened a PR with a proposed fix: 
[https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/84]

Could someone please take a look at it?

> Cannot create path-only mapping rule in /etc/map
> 
>
> Key: SLING-11352
> URL: https://issues.apache.org/jira/browse/SLING-11352
> Project: Sling
>  Issue Type: Bug
>  Components: ResourceResolver
>Affects Versions: Resource Resolver 1.8.4
>Reporter: Csaba Varga
>Priority: Minor
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> I am trying to set up a mapping to make some of our site hierarchy appear on 
> a different URL than what would be dictated by the hierarchy. My goal is to 
> map the path /content/mycompany/locales/some_locale/sectionA to the URL 
> /some_locale/sectionB . (I don't want to override the protocol, host and port 
> fields.) Because we support multiple locales, I need to use a regex for 
> setting up the matches. Here is my original attempt:
> {code:java}
> /etc/map/my_mapping
>  +-- sling:internalRedirect = 
> /content/mycompany/locales/([-a-z]+)/sectionA
>  +-- sling:match = /$1/sectionB{code}
> When this node is present, /content/mycompany/locales/en-us/sectionA/foo gets 
> mapped to /en-us://sectionB/foo instead of the intended /en-us/sectionB/foo.
> I can work around the issue by avoiding forward slashes in sling:match, but 
> this is ugly and unclear :
> {code:java}
> /etc/map/my_mapping
>  +-- sling:internalRedirect = 
> /content/mycompany/locales/([-a-z]+)(/)sectionA
>  +-- sling:match = /$1$2sectionB {code}
> Is this kind of mapping supported at all? I would rather avoid adding the 
> hostname to mapping rules because it is environment-specific.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (SLING-11352) Cannot create path-only mapping rule in /etc/map

2022-05-30 Thread Csaba Varga (Jira)


[ 
https://issues.apache.org/jira/browse/SLING-11352?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17543933#comment-17543933
 ] 

Csaba Varga commented on SLING-11352:
-

Looks like the issue is in the MapEntry.toURI method. Its comment says that it 
is only supposed to process absolute URIs and should return null for regular 
paths like "/the/path". It actually returns "/the://path" when given the input 
"/the/path".

toURI tries four regexes, but the fourth one is overly generic and will match 
anything that contains a forward slash anywhere but at the very beginning. The 
regexes look like they are meant to describe the whole string, so maybe they 
should be matched using Matcher.matches instead of Matcher.find. That way, none 
of them would match "/the/path" and the method would start working as 
documented.

> Cannot create path-only mapping rule in /etc/map
> 
>
> Key: SLING-11352
> URL: https://issues.apache.org/jira/browse/SLING-11352
> Project: Sling
>  Issue Type: Bug
>  Components: ResourceResolver
>Affects Versions: Resource Resolver 1.8.4
>Reporter: Csaba Varga
>Priority: Minor
>
> I am trying to set up a mapping to make some of our site hierarchy appear on 
> a different URL than what would be dictated by the hierarchy. My goal is to 
> map the path /content/mycompany/locales/some_locale/sectionA to the URL 
> /some_locale/sectionB . (I don't want to override the protocol, host and port 
> fields.) Because we support multiple locales, I need to use a regex for 
> setting up the matches. Here is my original attempt:
> {code:java}
> /etc/map/my_mapping
>  +-- sling:internalRedirect = 
> /content/mycompany/locales/([-a-z]+)/sectionA
>  +-- sling:match = /$1/sectionB{code}
> When this node is present, /content/mycompany/locales/en-us/sectionA/foo gets 
> mapped to /en-us://sectionB/foo instead of the intended /en-us/sectionB/foo.
> I can work around the issue by avoiding forward slashes in sling:match, but 
> this is ugly and unclear :
> {code:java}
> /etc/map/my_mapping
>  +-- sling:internalRedirect = 
> /content/mycompany/locales/([-a-z]+)(/)sectionA
>  +-- sling:match = /$1$2sectionB {code}
> Is this kind of mapping supported at all? I would rather avoid adding the 
> hostname to mapping rules because it is environment-specific.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)