real-user-agent
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -10,3 +10,3 @@ module.exports = () => all().then(d => d.shift()); | ||
const count = 10; // how many user agents (10) | ||
const fallbackString = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36'; | ||
const fallback = require('./ua'); | ||
const https = require('https'); | ||
@@ -66,3 +66,3 @@ | ||
console.error(err); | ||
data = Array.from(Array(count)).map(() => fallbackString); | ||
data = fallback; | ||
} | ||
@@ -69,0 +69,0 @@ } |
{ | ||
"name": "real-user-agent", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "get a real user-agent string sourced from top 10 current", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,3 +6,3 @@ # real-user-agent | ||
Get an up-to-date user-agent string, sourced from the [most common user agents](https://techblog.willshouse.com/2012/01/03/most-common-user-agents/). To avoid each use of this module hammering the source, the data is now self-hosted in this repository, [available via cdn](https://cdn.jsdelivr.net/gh/fijimunkii/real-user-agent@master/ua.json). A simple local cache, invalidated every 2 hours, prevents extra requests. A data cap is implemented in the request. There is a fallback string in case the data is corrupt or host is unreachable. | ||
Get an up-to-date user-agent string, sourced from the [most common user agents](https://techblog.willshouse.com/2012/01/03/most-common-user-agents/). To avoid each use of this module hammering the source, the data is now self-hosted in this repository, [available via cdn](https://cdn.jsdelivr.net/gh/fijimunkii/real-user-agent@master/ua.json). A simple local cache, invalidated every 2 hours, prevents extra requests. A data cap is implemented in the request. The local [ua.json](ua.json) is used as a fallback in case the data is corrupt or host is unreachable. | ||
@@ -9,0 +9,0 @@ ```js |
const userAgent = require('../index'); | ||
const uaJSON = require('../ua'); | ||
@@ -37,2 +38,8 @@ module.exports = t => { | ||
}); | ||
t.test('ua.json - is an array of 10 user agent strings', async (t) => { | ||
t.type(uaJSON, Array); | ||
t.same(uaJSON.length, 10); | ||
t.type(uaJSON[0], 'string'); | ||
t.same(uaJSON[0].substr(0, 13), 'Mozilla/5.0 ('); | ||
}); | ||
@@ -39,0 +46,0 @@ }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9250
179