BCJTI / ng2-cookies

Simple library to deal with cookies in Angular2
64 stars 31 forks source link

Prevent double regex testing when getting a cookie #61

Open Barryrowe opened 6 years ago

Barryrowe commented 6 years ago

When pulling a cookie value, the previous version was checking if it existed first (via REGEX) and then executing the same regex again to pull matches. While the .test() to check if it exists is going to be slightly quicker, it's still parsing the entire cookie set twice which adds overhead when reading an individual cookie.