diff --git a/index.js b/index.js index 0a90f6f..438ef1e 100644 --- a/index.js +++ b/index.js @@ -17,7 +17,7 @@ NullObject.prototype = Object.create(null) * obs-text = %x80-FF * quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text ) */ -const paramRE = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+)=("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g // eslint-disable-line no-control-regex +const paramRE = /; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu /** * RegExp to match quoted-pair in RFC 7230 sec 3.2.6 @@ -25,7 +25,7 @@ const paramRE = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+)=("(?:[\u000b\u0020\u0021\u0023 * quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text ) * obs-text = %x80-FF */ -const quotedPairRE = /\\([\u000b\u0020-\u00ff])/g // eslint-disable-line no-control-regex +const quotedPairRE = /\\([\v\u0020-\u00ff])/gu /** * RegExp to match type in RFC 7231 sec 3.1.1.1 @@ -34,7 +34,7 @@ const quotedPairRE = /\\([\u000b\u0020-\u00ff])/g // eslint-disable-line no-cont * type = token * subtype = token */ -const mediaTypeRE = /^[!#$%&'*+.^_|~0-9A-Za-z-]+\/[!#$%&'*+.^_|~0-9A-Za-z-]+$/ +const mediaTypeRE = /^[!#$%&'*+.^\w|~-]+\/[!#$%&'*+.^\w|~-]+$/u // default ContentType to prevent repeated object creation const defaultContentType = { type: '', parameters: new NullObject() }