Files
ccc-obfuscated-code/node_modules/validator/es/lib/isLatLong.js
Pipi Chen b8a3516cd6 update
2020-05-07 01:02:44 +08:00

10 lines
472 B
JavaScript

import assertString from './util/assertString';
var lat = /^\(?[+-]?(90(\.0+)?|[1-8]?\d(\.\d+)?)$/;
var _long = /^\s?[+-]?(180(\.0+)?|1[0-7]\d(\.\d+)?|\d{1,2}(\.\d+)?)\)?$/;
export default function (str) {
assertString(str);
if (!str.includes(',')) return false;
var pair = str.split(',');
if (pair[0].startsWith('(') && !pair[1].endsWith(')') || pair[1].endsWith(')') && !pair[0].startsWith('(')) return false;
return lat.test(pair[0]) && _long.test(pair[1]);
}