diff --git a/packages/marko-web-omeda-identity-x/utils/get-cookie-id.js b/packages/marko-web-omeda-identity-x/utils/get-cookie-id.js new file mode 100644 index 000000000..92d681b32 --- /dev/null +++ b/packages/marko-web-omeda-identity-x/utils/get-cookie-id.js @@ -0,0 +1,11 @@ +module.exports = (value, type) => { + if (!value) return null; + const trimmed = `${value.replace(/^"/, '').replace(/"$/, '')}`.trim(); + if (type === 'anon') { + return /^[a-z0-9-]{36}$/i.test(trimmed) ? trimmed : null; + } + if (type === 'enc') { + return /^[a-z0-9]{15}$/i.test(trimmed) ? trimmed : null; + } + return null; +};