feat(handler): sanitize sensitive fields in form data
- Removes `username` and `apiKey` from form data to prevent errors from the LanguageTool server when these fields are present - Updates test cases to reflect the new handling of form data bodies
This commit is contained in:
@@ -16,12 +16,16 @@ Deno.test('ltProxyHandler: proxies request and returns response', async () => {
|
||||
const originalFetch = globalThis.fetch;
|
||||
globalThis.fetch = async () => expectedResponse;
|
||||
|
||||
// Form body wie bei echtem Request
|
||||
const formData = new URLSearchParams({ text: 'Hallo Welt' });
|
||||
const bodyBytes = new TextEncoder().encode(formData.toString());
|
||||
|
||||
const req = new Request('http://localhost/v2/check?language=de-DE', {
|
||||
method: 'POST',
|
||||
body: new TextEncoder().encode('text=Hallo+Welt'),
|
||||
headers: {
|
||||
'content-type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
body: bodyBytes,
|
||||
});
|
||||
|
||||
const ctx: IContext = {
|
||||
@@ -30,7 +34,9 @@ Deno.test('ltProxyHandler: proxies request and returns response', async () => {
|
||||
query: {
|
||||
language: 'de-DE',
|
||||
},
|
||||
state: {},
|
||||
state: {
|
||||
body: bodyBytes,
|
||||
},
|
||||
};
|
||||
|
||||
const response = await ltProxyHandler(ctx);
|
||||
|
Reference in New Issue
Block a user