File tree Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Original file line number Diff line number Diff line change 22
33## Unreleased
44
5+ - Fix regression exceptions on specific corner cases with log obfuscation.
6+
57## 0.78.3
68
79- Add ` openai/gpt-5.1 ` to default models.
Original file line number Diff line number Diff line change 144144 m)))
145145
146146(defn obfuscate
147- " Obfuscate all but first 3 and last 3 characters of a string, minimum 5 characters .
147+ " Obfuscate all but first `preserve-num` and last `preserve-num` characters of a string.
148148 If the string is 4 characters or less, obfuscate all characters.
149149 Replace the middle part with asterisks, but always at least 5 asterisks."
150150 [s & {:keys [preserve-num]
151151 :or {preserve-num 3 }}]
152152 (when s
153- (string/replace
154- (if (<= (count s) 4 )
155- (apply str (repeat (count s) " *" ))
156- (str (subs s 0 preserve-num)
157- (apply str (repeat (- (count s) 4 ) " *" ))
158- (subs s (- (count s) preserve-num))))
159- (string/join " " (repeat (- (count s) 4 ) " *" )) " *****" )))
153+ (let [s (str s)
154+ len (count s)]
155+ (cond
156+ (zero? len)
157+ s
158+
159+ (<= len 4 )
160+ (apply str (repeat len " *" ))
161+
162+ :else
163+ (let [raw-preserve (max 0 preserve-num)
164+ max-preserve (quot len 2 )
165+ p (min raw-preserve max-preserve)
166+ middle-len (max 5 (- len (* 2 p)))
167+ stars (apply str (repeat middle-len " *" ))]
168+ (str (subs s 0 p)
169+ stars
170+ (subs s (- len p))))))))
160171
161172(defn normalize-model-name [model]
162173 (let [model-s (if (keyword? model)
You can’t perform that action at this time.
0 commit comments