mirror of
https://github.com/SunBK201/UA3F.git
synced 2025-12-16 08:44:29 +00:00
refactor: optimize length handling
This commit is contained in:
parent
5a8bd5e79e
commit
37107ac08d
@ -52,13 +52,14 @@ func (r *Rewriter) buildReplacement(srcAddr, dstAddr string, originalUA string,
|
||||
})
|
||||
|
||||
// Adjust to the exact length needed
|
||||
if len(newUA) >= n {
|
||||
newUALen := len(newUA)
|
||||
if newUALen >= n {
|
||||
return []byte(newUA[:n])
|
||||
}
|
||||
out := make([]byte, n)
|
||||
copy(out, newUA)
|
||||
// Pad with spaces if newUA is shorter than needed
|
||||
for i := len(newUA); i < n; i++ {
|
||||
for i := newUALen; i < n; i++ {
|
||||
out[i] = ' '
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user