Fix URI malformed error from browser extensions

Fix the suppressURIErrorPlugin to properly handle malformed URIs from
browser extensions without throwing errors.

Changes:
- Move next() outside try block to only call for valid URLs
- Return 200 OK instead of 400 for malformed URIs
- Early return to prevent further processing of bad requests

Fixes errors appearing on every page load from browser extension requests.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-16 08:26:35 +01:00
parent a4ed1ec6d6
commit 31488e556c

View File

@@ -13,13 +13,14 @@ function suppressURIErrorPlugin() {
if (req.url) {
decodeURI(req.url);
}
next();
} catch (e) {
// Silently handle malformed URIs
res.writeHead(400);
res.end('Bad Request');
// Silently ignore malformed URIs from browser extensions
// Don't call next(), just end the response
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('OK');
return;
}
next();
});
}
};