-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix two bugs #9
fix two bugs #9
Conversation
fix two bugs; 1: while the log variable in square brackets,like [$remote_addr] parser will throw Invalid regular expression; 2: when then variable is null ,this whole piece of log will parse to null
@@ -19,7 +20,7 @@ var Parser = module.exports = function (format) { | |||
this.directives[match[1]] = i++; | |||
if (match[2]) { | |||
boundary = this.escape(match[2]); | |||
regex = '([^' + boundary + ']+)' + boundary; | |||
regex = '([^' + boundary + ']+)?' + boundary; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
regex = '([^' + boundary + ']*?)' + boundary;
would be better here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That ?
in *?
look like not necessary, I change regex = '([^' + boundary + ']+)?'
to regex = '([^' + boundary + ']*)'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The *?
is not necessary, but it's slightly more efficient than a plain *
because it instructs the regex engine to match characters lazily.
for better perfermance
Can you provide an example as to when the variable will be null? It was my understanding that nginx outputs |
log_format main '[$seashell]'; |
replace [] into [-] while parse line
should fix parser for all case
fix two bugs;
1: while the log variable in square brackets,like
[$remote_addr] parser will throw Invalid regular expression;
2: when then variable is null ,this whole piece of log will parse to
null