@merchi/cart 1.4.63 → 1.4.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ /** A startup optimization only; explicit cart operations remain available. */
2
+ export function isAutomatedClient() {
3
+ var userAgent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : typeof navigator === 'undefined' ? '' : navigator.userAgent;
4
+ return /HeadlessChrome|bot|crawler|spider|slurp|SEBot-WA/i.test(userAgent);
5
+ }
@@ -0,0 +1,9 @@
1
+ import { isAutomatedClient } from './automatedClient';
2
+ describe('automated startup hint', function () {
3
+ it.each(['Mozilla/5.0 (X11; Linux x86_64) HeadlessChrome/153.0.8010.0 Safari/537.36', 'Mozilla/5.0 (compatible; Baiduspider-render/2.0)', 'Mozilla/5.0 (compatible; bingbot/2.0)', 'Mozilla/5.0 (compatible; Googlebot/2.1)', 'Mozilla/5.0 (compatible; SEBot-WA/1.0)'])('recognizes an automated visitor: %s', function (userAgent) {
4
+ expect(isAutomatedClient(userAgent)).toBe(true);
5
+ });
6
+ it.each(['', 'Mozilla/5.0 Chrome/153.0.0.0 Safari/537.36', 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_7 like Mac OS X) Version/26.6.1 Mobile/15E148 Safari/604.1', 'Mozilla/5.0 (Linux; Android 15) Chrome/153.0.0.0 Mobile Safari/537.36 [FBAN/FB4A]'])('keeps ordinary startup behavior: %s', function (userAgent) {
7
+ expect(isAutomatedClient(userAgent)).toBe(false);
8
+ });
9
+ });