UNPKG

@nimpl/ab-tests

Version:

A package for conducting A/B tests on a website using middleware

15 lines (14 loc) 559 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.checkCookie = void 0; const headers_1 = require("next/headers"); const checkCookie = (_url, rule) => { if (!rule.value) return { match: (0, headers_1.cookies)().has(rule.key), groups: {} }; const cookie = (0, headers_1.cookies)().get(rule.key); const match = cookie?.value?.match(`^${rule.value}$`); if (match) return { match: true, groups: match.groups || {} }; return { match: false, groups: {} }; }; exports.checkCookie = checkCookie;