@vllnt/analytics 0.1.1 → 0.2.0-canary.7824f2c

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.
package/src/consent.ts CHANGED
@@ -169,7 +169,11 @@ export function isDoNotTrackEnabled(): boolean {
169
169
  * Get consent from cookie (for SSR)
170
170
  */
171
171
  export function getConsentFromCookie(cookieString: string): boolean | null {
172
- const match = new RegExp(`${CONSENT_COOKIE_NAME}=([^;]+)`).exec(cookieString);
172
+ // Anchor to the start of the string or a cookie separator so that
173
+ // look-alike names such as "evil-vllnt-consent" are not matched.
174
+ const match = new RegExp(`(?:^|;\\s*)${CONSENT_COOKIE_NAME}=([^;]+)`).exec(
175
+ cookieString,
176
+ );
173
177
  if (!match) return null;
174
178
  return match[1] === "1";
175
179
  }