From 03a707884c591d56ad69c4c1ddd34cab0449b1fe Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Mon, 31 May 2021 18:59:21 +0200 Subject: [PATCH] [doc] Remove unsafe regex from code snippet --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 261ab95b0..c16df2036 100644 --- a/README.md +++ b/README.md @@ -395,7 +395,7 @@ the `X-Forwarded-For` header. ```js wss.on('connection', function connection(ws, req) { - const ip = req.headers['x-forwarded-for'].split(/\s*,\s*/)[0]; + const ip = req.headers['x-forwarded-for'].split(',')[0].trim(); }); ```