private String buildPath()

in src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/IncludeRuntimeExtension.java [77:103]


    private String buildPath(String path, Map options) {
        if (StringUtils.isEmpty(path)) {
            path = (String) options.get(OPTION_FILE);
        }
        if (StringUtils.isEmpty(path)) {
            return null;
        }
        String prependPath = (String) options.get(OPTION_PREPEND_PATH);
        if (prependPath == null) {
            prependPath = StringUtils.EMPTY;
        }
        if (StringUtils.isNotEmpty(prependPath)) {
            if (!prependPath.endsWith("/") && !path.startsWith("/")) {
                prependPath += "/";
            }
        }
        String appendPath = (String) options.get(OPTION_APPEND_PATH);
        if (appendPath == null) {
            appendPath = StringUtils.EMPTY;
        }
        if (StringUtils.isNotEmpty(appendPath)) {
            if (!appendPath.startsWith("/") && !path.endsWith("/")) {
                appendPath = "/" + appendPath;
            }
        }
        return prependPath + path + appendPath;
    }