cl
8 小时以前 c4bba32b20f0869b45ed14be04543869dd91ee6c
rsf-http-audit/src/main/java/com/vincent/rsf/httpaudit/support/HttpAuditSupport.java
@@ -55,7 +55,7 @@
    public static boolean shouldExclude(HttpServletRequest request, HttpAuditProperties props) {
        String path = safePath(request);
        for (String p : props.getExcludePathPrefixes()) {
        for (String p : props.getEffectiveExcludePrefixes()) {
            if (p != null && !p.isEmpty() && path.startsWith(p)) {
                return true;
            }
@@ -119,4 +119,29 @@
        }
        return s.substring(0, maxChars) + "...(truncated,len=" + s.length() + ")";
    }
    /** maxChars<0 不截断 */
    public static String storeWithCharLimit(String s, int maxChars) {
        if (s == null) {
            return null;
        }
        if (maxChars < 0) {
            return s;
        }
        return truncateForStore(s, maxChars);
    }
    public static boolean overCharLimit(String s, int maxChars) {
        return s != null && maxChars >= 0 && s.length() > maxChars;
    }
    public static String truncateUriForStore(String uri, int maxLen) {
        if (uri == null) {
            return "";
        }
        if (maxLen <= 0 || uri.length() <= maxLen) {
            return uri;
        }
        return uri.substring(0, maxLen - 3) + "...";
    }
}