mirror of
https://github.com/rxliuli/apps.apple.com.git
synced 2025-11-09 23:00:32 +00:00
init commit
This commit is contained in:
22
shared/utils/node_modules/@amp/runtime-detect/dist/rules.js
generated
vendored
Normal file
22
shared/utils/node_modules/@amp/runtime-detect/dist/rules.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
function applyRules(rules, navigator, data) {
|
||||
const { userAgent } = navigator !== null && navigator !== void 0 ? navigator : {};
|
||||
if (typeof userAgent !== 'string' || userAgent.trim() === '') {
|
||||
return data;
|
||||
}
|
||||
for (const rule of rules){
|
||||
const patterns = rule.slice(0, -1);
|
||||
const parser = rule[rule.length - 1];
|
||||
let match = null;
|
||||
for (const pattern of patterns){
|
||||
match = userAgent.match(pattern);
|
||||
if (match !== null) {
|
||||
Object.assign(data, parser(match, navigator, data));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (match !== null) break;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
export { applyRules };
|
||||
Reference in New Issue
Block a user