code: public static boolean hasSelector(@NotNull SlingHttpServletRequest request, @NotNull String expectedSelector) {
      String[] selectors = request.getRequestPathInfo().getSelectors();
      return ArrayUtils.contains(selectors, expectedSelector);
    }
docs: Checks if the given selector is present in the current URL request (at any position).
  @param request Sling request
  @param expectedSelector Selector string to check for.
  @return true if the selector was found