https://github.com/angular/angular
Raw File
Tip revision: 2668180cc7154805d6a32d8d18c48f958e3dbc30 authored by Joey Perrott on 05 October 2023, 14:58:44 UTC
fixup! ci: migrate snapshot publishing from CircleCI to GHA
Tip revision: 2668180
cookie.ts
/**
 * @license
 * Copyright Google LLC All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 */

export function parseCookieValue(cookieStr: string, name: string): string|null {
  name = encodeURIComponent(name);
  for (const cookie of cookieStr.split(';')) {
    const eqIndex = cookie.indexOf('=');
    const [cookieName, cookieValue]: string[] =
        eqIndex == -1 ? [cookie, ''] : [cookie.slice(0, eqIndex), cookie.slice(eqIndex + 1)];
    if (cookieName.trim() === name) {
      return decodeURIComponent(cookieValue);
    }
  }
  return null;
}
back to top