Skip to content

Commit 528b667

Browse files
authored
Extended charset detection to whole file in file contents
* extended charset detection to the whole file.
1 parent ee69bac commit 528b667

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
9+
## [1.5.1]- 2025-10-0
10+
### Added
11+
- Removed `Content-Length` from header as it is reported with Loadbalancer
12+
- Charset detection extended to the whole file
913

1014
## [1.5.0] - 2025-09-26
1115
### Added

pkg/service/filecontents_service.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ func (s APIService) FileContents(w http.ResponseWriter, r *http.Request) {
8484

8585
// detectCharset detects charset for a given text in a buffer.
8686
func detectCharset(buffer []byte) string {
87-
if len(buffer) > 32768 {
88-
buffer = buffer[:32768]
89-
}
9087
// Detect charset.
9188
result := chardet.Detect(buffer)
9289
// If confidence is low, consider it as UTF-8.

pkg/service/utils_service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const (
5555
TraceLogKey = "trace_id"
5656
CharsetDetectedKey = "X-Detected-Charset"
5757
ContentLengthKey = "Content-Length"
58-
CharSetMinConfidence = 0.6
58+
CharSetMinConfidence = 0.7
5959
)
6060

6161
// RequestContextKey Request ID Key name for using with Context.

0 commit comments

Comments
 (0)