real-user-agent
Advanced tools
Comparing version 1.0.4 to 2.0.0
11
index.js
@@ -16,5 +16,5 @@ module.exports = () => all().then(d => d.shift()); | ||
const options = { | ||
hostname: 'techblog.willshouse.com', | ||
hostname: 'gist.githubusercontent.com', | ||
port: 443, | ||
path: '/2012/01/03/most-common-user-agents/', | ||
path: '/fijimunkii/952acac988f2d25bef7e0284bc63c406/raw/ua.json', | ||
method: 'GET' | ||
@@ -35,8 +35,5 @@ }; | ||
} | ||
// extract JSON | ||
data = buffer.join('') | ||
.replace(/^[\S\s]*JSON.*\[/, '[') | ||
.replace(/\][\S\s]*$/, ']'); | ||
// extract data | ||
data = JSON.parse(data).map(d => d.useragent); | ||
data = buffer.join(''); | ||
data = JSON.parse(data); | ||
// data integrity | ||
@@ -43,0 +40,0 @@ data = data.filter(d => d.substr(0, 13) === 'Mozilla/5.0 ('); |
{ | ||
"name": "real-user-agent", | ||
"version": "1.0.4", | ||
"version": "2.0.0", | ||
"description": "get a real user-agent string sourced from top 10 current", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "node ./node_modules/.bin/tap test --jobs=10 --coverage-report=html --no-browser" | ||
"test": "node ./node_modules/.bin/tap test --jobs=10 --coverage-report=html --no-browser", | ||
"sync": "node sync.js" | ||
}, | ||
@@ -29,4 +30,5 @@ "repository": { | ||
"devDependencies": { | ||
"cloudscraper": "^4.1.2", | ||
"tap": "^12.4.0" | ||
} | ||
} |
@@ -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/). A simple cache, invalidated every 2 hours, prevents hammering the data source. 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 with [a gist](https://gist.githubusercontent.com/fijimunkii/952acac988f2d25bef7e0284bc63c406/raw/ua.json), updated in the build process. 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. | ||
@@ -9,0 +9,0 @@ ```js |
Sorry, the diff of this file is not supported yet
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
8858
7
186
2
1
2