summaryrefslogtreecommitdiff
path: root/shared/utils/node_modules/@amp/runtime-detect/dist/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'shared/utils/node_modules/@amp/runtime-detect/dist/rules.js')
-rw-r--r--shared/utils/node_modules/@amp/runtime-detect/dist/rules.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/shared/utils/node_modules/@amp/runtime-detect/dist/rules.js b/shared/utils/node_modules/@amp/runtime-detect/dist/rules.js
new file mode 100644
index 0000000..5ffb91f
--- /dev/null
+++ b/shared/utils/node_modules/@amp/runtime-detect/dist/rules.js
@@ -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 };