Apache
Home » Documentation » The Sling Engine

URL decomposition

During the Resource Resolution step, the client request URL is decomposed into the following parts:

  1. Resource Path - The longest substring of the request URL such that the resource path is either the complete request URL or the next character in the request URL after the resource path is a dot (.).
  2. Selectors - If the first character in the request URL after the resource path is a dot, the string after the dot up to but not including the last dot before the next slash character or the end of the request URL. If the resource path spans the complete request URL no seletors exist. If only one dot follows the resource path before the end of the request URL or the next slash, also no selectors exist.
  3. Extension - The string after the last dot after the resource path in the request URL but before the end of the request URL or the next slash after the resource path in the request URL.
  4. Suffix Path - If the request URL contains a slash character after the resource path and optional selectors and extension, the path starting with the slash up to the end of the request URL is the suffix path. Otherwise, the suffix path is empty. Note, that after the resource path at least a dot must be in the URL to let Sling detect the resource path.

There's a cheat sheet on Day's dev page under http://dev.day.com/content/docs/en/cq/current/developing/sling_cheatsheet.html available to get you familiar with the URL decomposition of Sling.

Examples: Assume there is a Resource at /a/b, which has no children.

URI Resource Path Selectors Extension Suffix Resource Found
/a/b /a/b null null null yes
/a/b.html /a/b null html null yes
/a/b.s1.html /a/b s1 html null yes
/a/b.s1.s2.html /a/b s1.s2 html null yes
/a/b/c/d /a/b/c/d null null null no!
/a/b./c/d /a/b null null /c/d yes
/a/b.html/c/d /a/b null html /c/d yes
/a/b.s1.html/c/d /a/b s1 html /c/d yes
/a/b.s1.s2.html/c/d /a/b s1.s2 html /c/d yes
/a/b/c/d.s.txt /a/b/c/d s txt null no!
/a/b.html/c/d.s.txt /a/b null html /c/d.s.txt yes
/a/b.s1.html/c/d.s.txt /a/b s1 html /c/d.s.txt yes
/a/b.s1.s2.html/c/d.s.txt /a/b s1.s2 html /c/d.s.txt yes
Automated tests and examples
The SlingRequestPathInfoTest demonstrates and tests this decomposition. Feel free to suggest additional tests that help clarify how this works!
Rev. 1500501 by fmeschbe on Sun, 7 Jul 2013 18:49:51 +0000
Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.