package cn.qihangerp.service.external.sph;

/**
 * 微信小店调用日志：URL 脱敏与片段截断。
 *
 * @author guochengyu
 */
final class WeixinShopEcLogSupport {

    private WeixinShopEcLogSupport() {
    }

    static String redactAccessTokenInUrl(String url) {
        if (url == null || url.isBlank()) {
            return url;
        }
        return url.replaceAll("access_token=[^&]+", "access_token=***");
    }

    static String snippet(String s, int max) {
        if (s == null) {
            return null;
        }
        return s.length() <= max ? s : s.substring(0, max);
    }
}
