@haluo/util 1.0.25 → 1.0.27

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.
@@ -13,14 +13,38 @@ var __assign = (this && this.__assign) || function () {
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  var uuidv4 = require('uuid').v4;
15
15
  // const Parser = require('ua-parser-js');
16
+ var reg = /((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}/g;
16
17
  var SendTracker = /** @class */ (function () {
17
18
  function SendTracker() {
18
19
  this.url = '';
19
20
  }
21
+ SendTracker.prototype.verifyRequest = function (reason) {
22
+ if (!reason)
23
+ return false;
24
+ if (reg.test(reason))
25
+ return false;
26
+ if (reason.startsWith('halomoto:'))
27
+ return false;
28
+ if (reason.startsWith('file:'))
29
+ return false;
30
+ if (reason.includes('log-center.58moto.com'))
31
+ return false;
32
+ if (reason.includes('s23.cnzz.com'))
33
+ return false;
34
+ if (reason.includes('g.alicdn.com'))
35
+ return false;
36
+ return true;
37
+ };
20
38
  SendTracker.prototype.send = function (data) {
21
39
  if (data === void 0) { data = {}; }
22
- if (window.location.host.indexOf('localhost') > -1)
40
+ var host = window.location.host;
41
+ if (host.indexOf('localhost') > -1)
42
+ return;
43
+ if (reg.test(host))
44
+ return;
45
+ if (!this.verifyRequest(data.reason))
23
46
  return;
47
+ data.reason = window.location.href + ' ' + data.reason;
24
48
  var log = __assign(__assign({}, getExtraData()), data);
25
49
  var formBody = [];
26
50
  for (var property in log) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haluo/util",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "main": "./dist/index.js",
5
5
  "author": "<wanghui@jddmoto.com>",
6
6
  "description": "哈罗摩托工具库",
@@ -1,12 +1,28 @@
1
1
  const { v4: uuidv4 } = require('uuid')
2
2
  // const Parser = require('ua-parser-js');
3
+ const reg = /((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}/g
4
+
3
5
  class SendTracker {
4
6
  url: string
5
7
  constructor() {
6
8
  this.url = ''
7
9
  }
10
+ verifyRequest(reason:string):boolean {
11
+ if(!reason) return false
12
+ if(reg.test(reason)) return false
13
+ if(reason.startsWith('halomoto:')) return false
14
+ if(reason.startsWith('file:')) return false
15
+ if(reason.includes('log-center.58moto.com')) return false
16
+ if(reason.includes('s23.cnzz.com')) return false
17
+ if(reason.includes('g.alicdn.com')) return false
18
+ return true
19
+ }
8
20
  send(data:any = {}) {
9
- if(window.location.host.indexOf('localhost') > -1) return
21
+ const host = window.location.host
22
+ if(host.indexOf('localhost') > -1) return
23
+ if(reg.test(host)) return
24
+ if(!this.verifyRequest(data.reason)) return
25
+ data.reason = window.location.href+' '+data.reason
10
26
  const log = { ...getExtraData(), ...data}
11
27
  let formBody: any = [];
12
28
  for (var property in log) {