AEM resource resolver failing

I am working on the AEM resource resolver and I currently have the following configuration on the Adobe Sling Resource Resolver Factory.

/content/mywebsite/>/

I have this a tag being generated from a component that looks something like:

<a data-desktop='/content/mywebsite/desktop.html'
   data-android-href='/content/mywebsite/android.html' 
   data-ios-href='/content/mywebsite/mywebsite/ios.html'
   href='/content/mywebsite/normal.html'>Click here</a>

This should have ideally been resolved to something likeL

<a data-desktop='/desktop.html'
 data-adroid-href='/android.html'
 data-ios-href='ios.html' 
 href='/normal.html'>Click here</a>

The irony is the last href in the above a tag is also not resolved by the resource resolver and I'm still getting the unresolved URL on dispatcher.

All the other resource resolver for a tags with just <a href='/content/mywebsite/something.html></a>' gets resolved. I don't understand why the resource resolver does not pick up the one with multiple data elements.

Upvotes: 1

Views: 2764

Answers (1)

toniedzwiedz
toniedzwiedz

Reputation: 18553

Are you sure it depends on the number of attributes? It looks like your configuration only affects resource resolution and not the outgoing mapping. The rule will be applied for incoming requests so when the user hits your AEM instance with /something.html, the Resource Resolver will look for the resource at /content/mywebsite.something, as well as other paths mapped to the root (if any) but as far as I understand, it will not affect the way AEM renders links to that content.

Try changing your rule so that it uses a two way mapping: /content/mywebsite/:/

To quote the description of the URL Mappings field in the Apache Sling Resource Resolver Factory configuration in the OSGi console:

List of mappings to apply to paths. Incoming mappings are applied to request paths to map to resource paths, outgoing mappings are applied to map resource paths to paths used on subsequent requests. Form is <internalPathPrefix><op><externalPathPrefix> where <op> is ">" for incoming mappings, "<" for outgoing mappings and ":" for mappings applied in both directions. Mappings are applied in configuration order by comparing and replacing URL prefixes. Note: The use of "-" as the <op> value indicating a mapping in both directions is deprecated. (resource.resolver.mapping)

You can easily test the configurations you setin the Apache Sling Resource Resolver Factory using the Configuration Test field on the Resource Resolver page in the OSGi console. You'll find it at http://<host>:<port>/system/console/jcrresolver

Use the Resolve and Map buttons to se.e how the path is transformed both ways.

Also, if you're getting inconsistent behaviour between components, check if they both map the URLs using resourceResolver#map if not covered by the Externalizer already.

Upvotes: 1

Related Questions