private Set getSelectorsFromPath()

in src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/ResourceRuntimeExtension.java [304:325]


        private Set<String> getSelectorsFromPath(String path) {
            Set<String> selectors = new LinkedHashSet<>();
            if (path != null) {
                String processingPath = path;
                int lastSlashPos = path.lastIndexOf('/');
                if (lastSlashPos > -1) {
                    processingPath = path.substring(lastSlashPos + 1, path.length());
                }
                int dotPos = processingPath.indexOf('.');
                if (dotPos > -1) {
                    int lastDotPos = processingPath.lastIndexOf('.');
                    // We're expecting selectors only when an extension is also present. If there's
                    // one dot it means we only have the extension
                    if (lastDotPos > dotPos) {
                        String selectorString = processingPath.substring(dotPos + 1, lastDotPos);
                        String[] selectorParts = selectorString.split("\\.");
                        selectors.addAll(Arrays.asList(selectorParts));
                    }
                }
            }
            return selectors;
        }