Whole file

slomkowski/nginx-config-formatter

The author described this change as Fix error which split line when it contained backslash. Fixes #5. It counts as a record because the checks below fail on the code as it stood at 4488f2ee6 and pass on f5a26225b, with nothing else changed between the two runs.

Fix saved2017-07-26
Sharing licenceApache-2.0 · LICENSE
Change size+5 4

What the code was meant to do, written into the code itself as a save note

Fix error which split line when it contained backslash. Fixes #5

The change

1313
1414 __author__ = "Michał Słomkowski"
1515 __license__ = "Apache 2.0"
16-__version__ = "1.0.1"
16+__version__ = "1.0.2"
1717
1818 INDENTATION = ' ' * 4
1919
5454 flags=re.UNICODE)
5555
5656
57-def clean_lines(orig_lines):
57+def clean_lines(orig_lines) -> list:
5858 """Strips the lines and splits them if they contain curly brackets."""
5959 cleaned_lines = []
6060 for line in orig_lines:
6868 cleaned_lines.append(strip_variable_template_tags(line))
6969 else:
7070 cleaned_lines.extend(
71- [strip_variable_template_tags(l).strip() for l in re.split(r"([{\\}])", line) if l != ""])
71+ [strip_variable_template_tags(l).strip() for l in re.split(r"([{}])", line) if l != ""])
7272
7373 return cleaned_lines
7474
105105
106106 def format_config_contents(contents):
107107 """Accepts the string containing nginx configuration and returns formatted one. Adds newline at the end."""
108- lines = clean_lines(contents.splitlines())
108+ lines = contents.splitlines()
109+ lines = clean_lines(lines)
109110 lines = join_opening_bracket(lines)
110111 lines = perform_indentation(lines)
111112

The check that tells the two apart

failpass·test_nginxfmt.py::TestFormatter::test_backslash
failpass·test_nginxfmt.py::TestFormatter::test_clean_lines

Check file test_nginxfmt.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it4488f2ee63fa73a20a3499f145277dec8cb2f0c2
Broken version dated2017-07-20
Modulenginxfmt
Units changedclean_lines, format_config_contents
Fingerprintf6cae73c854eb0d6
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in slomkowski/nginx-config-formatter