code: public String getExtension() {
          String extension = getSlingRequest().getRequestPathInfo().getExtension();
          return StringUtils.isBlank(extension) ? "" : ("." + extension);
      }
docs: Returns the request extension with a leading '.' if present.