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:
@@ -13,13 +13,14 @@ function suppressURIErrorPlugin() {
|
|||||||
if (req.url) {
|
if (req.url) {
|
||||||
decodeURI(req.url);
|
decodeURI(req.url);
|
||||||
}
|
}
|
||||||
next();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Silently handle malformed URIs
|
// Silently ignore malformed URIs from browser extensions
|
||||||
res.writeHead(400);
|
// Don't call next(), just end the response
|
||||||
res.end('Bad Request');
|
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
||||||
|
res.end('OK');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
next();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user