Comparing version
@@ -1,5 +0,3 @@ | ||
"use strict"; | ||
const request = require("jsonrequest"); | ||
var request = require("jsonrequest"); | ||
/** | ||
@@ -19,4 +17,4 @@ * ipInfo | ||
*/ | ||
var ipInfo = module.exports = function (type, token, callback) { | ||
var url = null; | ||
const ipInfo = module.exports = function (type, token, callback) { | ||
let url = null; | ||
@@ -33,9 +31,9 @@ if (typeof token === "function") { | ||
if (typeof token === "string") { | ||
if(typeof token === "string") { | ||
if (!type) { | ||
url = ipInfo.HOSTNAME_SSL + "/json" + ipInfo.TOKEN_PREFIX + token; | ||
url = ipInfo.HOSTNAME_SSL + "/json" + ipInfo.TOKEN_PREFIX + token; | ||
} else if (ipInfo.IP_REGEX.test(type)) { | ||
url = ipInfo.HOSTNAME_SSL + type + "/json" + ipInfo.TOKEN_PREFIX + token; | ||
url = ipInfo.HOSTNAME_SSL + type + "/json" + ipInfo.TOKEN_PREFIX + token; | ||
} else { | ||
url = ipInfo.HOSTNAME_SSL + type + ipInfo.TOKEN_PREFIX + token; | ||
url = ipInfo.HOSTNAME_SSL + type + ipInfo.TOKEN_PREFIX + token; | ||
} | ||
@@ -52,4 +50,4 @@ } else { | ||
request(url, function (err, body) { | ||
if (err && err.message.startsWith("Unexpected token")) { | ||
request(url, (err, body) => { | ||
if (err && err.message && err.message.startsWith("Unexpected token")) { | ||
err = null; | ||
@@ -67,2 +65,2 @@ } | ||
ipInfo.TOKEN_PREFIX = "?token="; | ||
ipInfo.IP_REGEX = /^\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b$/; | ||
ipInfo.IP_REGEX = /^\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b$/; |
{ | ||
"name": "ipinfo", | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"description": "An http://ipinfo.io NodeJS wrapper.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
# ipinfo | ||
[][patreon] [][paypal-donations] [](https://github.com/IonicaBizau/ama) [](https://www.npmjs.com/package/ipinfo) [](https://www.npmjs.com/package/ipinfo) [](https://www.codementor.io/johnnyb?utm_source=github&utm_medium=button&utm_term=johnnyb&utm_campaign=github) | ||
[][paypal-donations] [](https://github.com/IonicaBizau/ama) [](https://www.npmjs.com/package/ipinfo) [](https://www.npmjs.com/package/ipinfo) [](https://www.codementor.io/johnnyb?utm_source=github&utm_medium=button&utm_term=johnnyb&utm_campaign=github) | ||
@@ -73,12 +73,2 @@ > An http://ipinfo.io NodeJS wrapper. | ||
## :moneybag: Donations | ||
Another way to support the development of my open-source modules is | ||
to [set up a recurring donation, via Patreon][patreon]. :rocket: | ||
[PayPal donations][paypal-donations] are appreciated too! Each dollar helps. | ||
Thanks! :heart: | ||
## :dizzy: Where is this library used? | ||
@@ -97,3 +87,2 @@ If you are using this library in one of your projects, add it in this list. :sparkles: | ||
[patreon]: https://www.patreon.com/ionicabizau | ||
[paypal-donations]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RVXDDLKKLQRJW | ||
@@ -100,0 +89,0 @@ [donate-now]: http://i.imgur.com/6cMbHOC.png |
7097
-5.25%93
-10.58%