Merge pull request #699 from lbryio/fixFailedLogClamp
Fix failed referrer clamp in logMetrics
This commit is contained in:
commit
e6400542e2
1 changed files with 8 additions and 2 deletions
|
@ -10,8 +10,14 @@ function logMetricsMiddleware(req, res, next) {
|
||||||
let referrer = req.get('referrer');
|
let referrer = req.get('referrer');
|
||||||
|
|
||||||
if(referrer && referrer.length > 255) {
|
if(referrer && referrer.length > 255) {
|
||||||
|
try {
|
||||||
// Attempt to "safely" clamp long URLs
|
// Attempt to "safely" clamp long URLs
|
||||||
referrer = /(.*?)#.*/.exec(referrer)[1];
|
referrer = /(.*?)#.*/.exec(referrer)[1];
|
||||||
|
} catch(e) {
|
||||||
|
// Cheap forced string conversion & clamp
|
||||||
|
referrer = new String(referrer);
|
||||||
|
referrer = referrer.substr(0, 255);
|
||||||
|
}
|
||||||
|
|
||||||
if(referrer.length > 255) {
|
if(referrer.length > 255) {
|
||||||
logger.warn('Request refferer exceeds 255 characters:', referrer);
|
logger.warn('Request refferer exceeds 255 characters:', referrer);
|
||||||
|
|
Loading…
Add table
Reference in a new issue