madmurphy / cookies.js

Simple cookie framework with full Unicode support
GNU General Public License v3.0
264 stars 54 forks source link

eslint no-useless-escape #8

Closed panhezeng closed 6 years ago

panhezeng commented 6 years ago

For example /[\-\.\+\*]/g Better /[-.+*]/g

For example /^(?:expires|max\-age|path|domain|secure)$/i Better /^(?:expires|max-age|path|domain|secure)$/I

For example /((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g Better /((?:^|\s*;)[^=]+)(?=;|$)|^\s*|\s*(?:=[^;]*)?(?:\1|$)/g

madmurphy commented 6 years ago

@panhezeng

Thank you for the review! But the characters =, -, ., + and * are considered metacharacters in regular expressions and – at least in my opinion – should always be escaped when they represent normal characters.

Best,

--madmurphy