Skip to content

Commit f9e0f7d

Browse files
authored
Fix IP addresses being treated as Base64 (#102)
1 parent 0d88c77 commit f9e0f7d

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"dependencies": {
1818
"axios": "0.11.1",
1919
"form-data": "0.2.0",
20-
"promise": "7.1.1"
20+
"promise": "7.1.1",
21+
"valid-url": "^1.0.9"
2122
},
2223
"devDependencies": {
2324
"babel-eslint": "^6.1.2",

src/constants.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const MAX_BATCH_SIZE = 128;
22
const GEO_LIMIT_TYPES = ['withinMiles', 'withinKilometers', 'withinRadians', 'withinDegrees'];
3-
const URL_REGEX = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/i;
43
const SYNC_TIMEOUT = 240000;
54
const MODEL_QUEUED_FOR_TRAINING = '21103';
65
const MODEL_TRAINING = '21101';
@@ -67,7 +66,6 @@ module.exports = {
6766
},
6867
GEO_LIMIT_TYPES,
6968
MAX_BATCH_SIZE,
70-
URL_REGEX,
7169
SYNC_TIMEOUT,
7270
POLLTIME
7371
};

src/utils.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
let Promise = require('promise');
2-
let {URL_REGEX, GEO_LIMIT_TYPES, ERRORS} = require('./constants');
2+
let validUrl = require('valid-url');
3+
let {GEO_LIMIT_TYPES, ERRORS} = require('./constants');
34
let {checkType, clone} = require('./helpers');
45
let {version: VERSION} = require('./../package.json');
56

@@ -86,7 +87,7 @@ module.exports = {
8687
formatMediaPredict: (data, type = 'image') => {
8788
let media;
8889
if (checkType(/String/, data)) {
89-
if (URL_REGEX.test(data) === true) {
90+
if (validUrl.isWebUri(data)) {
9091
media = {
9192
url: data
9293
};

0 commit comments

Comments
 (0)