-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient.js
More file actions
35 lines (28 loc) · 787 Bytes
/
client.js
File metadata and controls
35 lines (28 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* @file 浏览器检测模块。
*/
// @ts-check
const core = require('./lib/core');
const os = require('./os');
const browserRules = require('./rules/browser');
const clientRules = require('./rules/client');
/** @typedef { import('./lib/core').MatchingResult } MatchingResult */
const pcRules = browserRules.spiderBotRules
.concat(clientRules.pcRules)
.concat(browserRules.pcRules);
const mobileRules = browserRules.spiderBotRules
.concat(clientRules.mobileRules)
.concat(browserRules.mobileRules);
/**
* 执行客户端类型匹配。
* @param {string} ua 用户代理字符串。
* @returns {MatchingResult} 匹配结果。
*/
exports.exec = (ua) => {
return core.execRules(
ua,
'client',
os.exec(ua).isPC ? pcRules : mobileRules,
2
);
};