private static int getUrlOffset(@NotNull CharSequence chars, int startOffset, int endOffset) {
    @SuppressWarnings("HttpUrlsUsage") final String[] URL_PREFIX = { "http://", "https://", "ftp://"};
    for (String urlPrefix : URL_PREFIX) {
      int urlOffset = CharArrayUtil.indexOf(chars, urlPrefix, startOffset, endOffset);
      if (urlOffset >= 0) {
        return urlOffset;
      }
    }
    return -1;
  }
private static int getUrlOffset(@NotNull CharSequence chars, int startOffset, int endOffset)