Skip to content

Commit

Permalink
chore: when decoding a response, the decoder now attempts to automati…
Browse files Browse the repository at this point in the history
…cally determine the encoding via the `Content-Type` header
  • Loading branch information
spuxx1701 committed Oct 29, 2023
1 parent ca1eaa4 commit f101a9d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).

## [2.2.2] - 2023-10-29

### Changed

- When decoding a response, the decoder now attempts to automatically determine the encoding via the `Content-Type` header.

### Fixed

- Fixed an issue where the application would get confused about the session state if the user logs out globally via the forum's logout functionality.
Expand Down
6 changes: 5 additions & 1 deletion src/http/http.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ export class HttpService {
),
);
if (decode) {
const decoder = new TextDecoder('iso-8859-15');
const contentTypeHeader: string = (response as any).headers[
'content-type'
];
const decoding = contentTypeHeader?.split('charset=')[1];
const decoder = new TextDecoder(decoding?.toLowerCase() ?? 'iso-8859-15');
const text = decoder.decode(response.data as ArrayBuffer);
response.data = text;
}
Expand Down
1 change: 0 additions & 1 deletion src/threads/controllers/threads.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ export class ThreadsController {
@Request() request: ExpressRequest,
@Query() query: ThreadsFindByIdQuery,
): Promise<ThreadReadResource> {
console.log(query);
return this.service.findById(id, request.user, {
...query,
});
Expand Down

0 comments on commit f101a9d

Please sign in to comment.