bithavoc / express-winston

express.js middleware for winstonjs
https://www.npmjs.com/package/express-winston
MIT License
798 stars 186 forks source link

Allow line breaks inside `msg` interpolation boundaries #135

Closed ltegman closed 7 years ago

ltegman commented 7 years ago

The current regex for string interpolation boundaries in the msg field is /\{\{(.+?)\}\}/g, which does not allow line breaks inside the interpolated area. This can lead to really difficult to read code if the statement being interpolated is lengthy. Would you be open to a PR changing this regex to something like /\{\{((?:.|\s)+?)\}\}/g, which would allow linebreaks?

rosston commented 7 years ago

Sure! Any reason not to simply make it /\{\{([\s\S]+?)\}\}/g though? I'm not sure I see the reasoning of the non-capturing group ((?:.|\s)) in yours.

Edit I was using lodash's default as reference: https://github.com/lodash/lodash/blob/4.11.2/lodash.js#L114

ltegman commented 7 years ago

Nope, your regex looks like the simpler solution! I'll put in a PR for this tonight or tomorrow :smile: