mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-09-27 07:58:45 +03:00
[submodule:extensions] Restore Bots
as an umbrella term for any kind of automated browsers: CLIs
, Crawlers
, Fetchers
, and Modules
This commit is contained in:
parent
391b8087fb
commit
f00fb3a2e2
1
src/extensions/ua-parser-extensions.d.ts
vendored
1
src/extensions/ua-parser-extensions.d.ts
vendored
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
import type { UAParserExt } from "../main/ua-parser";
|
import type { UAParserExt } from "../main/ua-parser";
|
||||||
|
|
||||||
|
export const Bots: UAParserExt;
|
||||||
export const CLIs: UAParserExt;
|
export const CLIs: UAParserExt;
|
||||||
export const Crawlers: UAParserExt;
|
export const Crawlers: UAParserExt;
|
||||||
export const ExtraDevices: UAParserExt;
|
export const ExtraDevices: UAParserExt;
|
||||||
|
@ -342,7 +342,21 @@ const Modules = Object.freeze({
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//////////
|
||||||
|
// BOTS
|
||||||
|
/////////
|
||||||
|
|
||||||
|
const Bots = Object.freeze({
|
||||||
|
browser : [
|
||||||
|
...CLIs.browser,
|
||||||
|
...Crawlers.browser,
|
||||||
|
...Fetchers.browser,
|
||||||
|
...Modules.browser
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
Bots,
|
||||||
CLIs,
|
CLIs,
|
||||||
Crawlers,
|
Crawlers,
|
||||||
ExtraDevices,
|
ExtraDevices,
|
||||||
|
@ -9,7 +9,7 @@ const crawlers = require('./specs/browser-crawlers.json');
|
|||||||
const emails = require('./specs/browser-emails.json');
|
const emails = require('./specs/browser-emails.json');
|
||||||
const fetchers = require('./specs/browser-fetchers.json');
|
const fetchers = require('./specs/browser-fetchers.json');
|
||||||
const modules = require('./specs/browser-modules.json');
|
const modules = require('./specs/browser-modules.json');
|
||||||
const { CLIs, Crawlers, Emails, Fetchers, Modules } = require('../src/extensions/ua-parser-extensions');
|
const { Bots, CLIs, Crawlers, Emails, Fetchers, Modules } = require('../src/extensions/ua-parser-extensions');
|
||||||
|
|
||||||
describe('Extensions', () => {
|
describe('Extensions', () => {
|
||||||
[
|
[
|
||||||
@ -38,6 +38,8 @@ describe('Extensions', () => {
|
|||||||
const jsdom = 'Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/20.0.3';
|
const jsdom = 'Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/20.0.3';
|
||||||
const scrapy = 'Scrapy/1.5.0 (+https://scrapy.org)';
|
const scrapy = 'Scrapy/1.5.0 (+https://scrapy.org)';
|
||||||
|
|
||||||
|
assert.equal(UAParser(scrapy, Bots).browser.name, 'Scrapy');
|
||||||
|
|
||||||
const emailParser = new UAParser(Emails);
|
const emailParser = new UAParser(Emails);
|
||||||
assert.deepEqual(emailParser.setUA(outlook).getBrowser(), {name: "Microsoft Outlook", version: "16.0.9126", major: "16", type: "email"});
|
assert.deepEqual(emailParser.setUA(outlook).getBrowser(), {name: "Microsoft Outlook", version: "16.0.9126", major: "16", type: "email"});
|
||||||
assert.deepEqual(emailParser.setUA(thunderbird).getBrowser(), {name: "Thunderbird", version: "78.13.0", major: "78", type: "email"});
|
assert.deepEqual(emailParser.setUA(thunderbird).getBrowser(), {name: "Thunderbird", version: "78.13.0", major: "78", type: "email"});
|
||||||
@ -67,7 +69,7 @@ describe('Merge', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Testing regexes', () => {
|
describe('Testing the safety of regexes', () => {
|
||||||
|
|
||||||
let regexes;
|
let regexes;
|
||||||
let code = fs.readFileSync('src/extensions/ua-parser-extensions.js', 'utf8').toString();
|
let code = fs.readFileSync('src/extensions/ua-parser-extensions.js', 'utf8').toString();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user