diff --git a/crossplane/builder.py b/crossplane/builder.py index 6dbe86f..4cb3831 100644 --- a/crossplane/builder.py +++ b/crossplane/builder.py @@ -96,10 +96,7 @@ def _build_lines(objs): state['depth'] = state['depth'] + 1 for obj in objs: - directive = obj['directive'] - - if directive == '': - directive = _enquote(directive) + directive = _enquote(obj['directive']) if directive in EXTERNAL_BUILDERS: external_builder = EXTERNAL_BUILDERS[directive] diff --git a/tests/configs/directive-with-space/nginx.conf b/tests/configs/directive-with-space/nginx.conf new file mode 100644 index 0000000..f187048 --- /dev/null +++ b/tests/configs/directive-with-space/nginx.conf @@ -0,0 +1,8 @@ +events { +} +http { + map $http_user_agent $mobile { + default 0; + '~Opera Mini' 1; + } +} diff --git a/tests/test_build.py b/tests/test_build.py index 9c09443..45a35a2 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -256,3 +256,7 @@ def test_compare_parsed_and_built_russian_text(tmpdir): def test_compare_parsed_and_built_quoted_right_brace(tmpdir): compare_parsed_and_built('quoted-right-brace', 'nginx.conf', tmpdir) + + +def test_compare_parsed_and_built_directive_with_space(tmpdir): + compare_parsed_and_built('directive-with-space', 'nginx.conf', tmpdir)