vasilevich / nginxbeautifier

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

fix: fix an indent problem when a bracket is followed by a comment. #25

Closed Clarkkkk closed 1 year ago

Clarkkkk commented 1 year ago

Bracket lines followed by a comment are indented incorrectly. For example:

server {
    if ($host = example.com) {
        return 301 https://$host$request_uri;
        } # managed by Certbot

        listen 80;
        server_name example.com;
        return 404; # managed by Certbot
    }

should be:

server {
    if ($host = example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    listen       80;
    server_name  example.com;
    return 404; # managed by Certbot
}

Fix it by using regular expressions to match those kind of lines.