diff --git a/__tests__/parse.test.ts b/__tests__/parse.test.ts index 59e3568..5b6c321 100644 --- a/__tests__/parse.test.ts +++ b/__tests__/parse.test.ts @@ -519,4 +519,13 @@ describe('parseContentType', () => { parameters: { name: 'prüfbericht.pdf' }, }); }); + + // Issue #17: https://github.com/mat-sz/letterparser/issues/17 + it('should handle empty space correctly', () => { + expect(parseContentType('text/plain; charset = "utf-8"')).toMatchObject({ + type: 'text/plain', + encoding: 'utf-8', + parameters: { charset: 'utf-8' }, + }); + }); }); diff --git a/src/parser.ts b/src/parser.ts index 79c3a5d..417fc96 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -35,7 +35,7 @@ export function parseHeaderValue( continue; } - let value = parameterSplit[1]; + let value = parameterSplit[1].trim(); if (parameterSplit.length > 2) { value = parameterSplit.slice(1).join('='); }