vasilevich / nginxbeautifier

Format and beautify nginx config files
https://nginxbeautifier.com
Apache License 2.0
164 stars 20 forks source link

Treat mutli-line parameters correctly #26

Open Gaibhne opened 1 year ago

Gaibhne commented 1 year ago

I think the following is a common use case of how people want their config files to look:

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';

After running the formatter, neither outcome looks appealing to me:

With -a/--align:

log_format           main '$remote_addr - $remote_user [$time_local] "$request" '
'$status             $body_bytes_sent "$http_referer" '
'"$http_user_agent"  "$http_x_forwarded_for"';

Without -a/--align:

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
Gaibhne commented 1 year ago

Come to think about it, I think the -a variant is even actually a bug: it's inserting additional spaces/tabs in the log format string, which I would think would lead to the logs looking differently after formatting the config.