not-node 6.5.60 → 6.5.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "not-node",
3
- "version": "6.5.60",
3
+ "version": "6.5.61",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/common.js CHANGED
@@ -342,17 +342,14 @@ module.exports.generatePaths = (content = [], relative = "src") => {
342
342
  **/
343
343
  module.exports.getIP = (req) => {
344
344
  if (req) {
345
- const ip =
345
+ return (
346
346
  (req.headers && req.headers["x-forwarded-for"]) ||
347
347
  (req.connection && req.connection.remoteAddress) ||
348
348
  (req.socket && req.socket.remoteAddress) ||
349
349
  (req.connection &&
350
350
  req.connection.socket &&
351
- req.connection.socket.remoteAddress);
352
- if (ip && ip.indexOf(",") > -1) {
353
- return ip.split(",")[0];
354
- }
355
- return ip;
351
+ req.connection.socket.remoteAddress)
352
+ );
356
353
  } else {
357
354
  return undefined;
358
355
  }
@@ -2,7 +2,14 @@ module.exports = [
2
2
  ...require("./string"),
3
3
  {
4
4
  validator(val, { validator }) {
5
- return validator.isIP(val);
5
+ if (val.indexOf(",") > -1) {
6
+ return val
7
+ .split(",")
8
+ .map((ip) => ip.trim())
9
+ .every((ip) => validator.isIP(ip));
10
+ } else {
11
+ return validator.isIP(val);
12
+ }
6
13
  },
7
14
  message: "not-node:value_is_not_ip_address",
8
15
  },
@@ -675,7 +675,12 @@ describe("Core Validators", () => {
675
675
  });
676
676
  });
677
677
 
678
- const listOfValidValues = ["127.0.1.1", "10.8.1.10", "0.0.0.0"];
678
+ const listOfValidValues = [
679
+ "127.0.1.1",
680
+ "10.8.1.10",
681
+ "0.0.0.0",
682
+ "123.1.1.4, 192.123.4.1",
683
+ ];
679
684
  listOfValidValues.forEach((val) => {
680
685
  it(
681
686
  "valid: " + val,