Skip to content

String folding of certain folded block scalar values is ugly #422

Closed
@havran

Description

@havran

Describe the bug
Hi. Seems like for some specific multiline strings, output of stringify() is formatted invalid.

To Reproduce

Example:

console.log(
  stringify({
    'nginx.ingress.kubernetes.io/configuration-snippet':
      'location ~* ^/sites/aaaaaaa.aa/files/(.+) {\n  return 302 https://process.aaaaaaa.aa/sites/aaaaaaa.aa/files/$1;\n}\nlocation ~* ^/partner-application/cls/(.+) {\n  return 301 https://process.aaaaaaa.aa/partner-application/cls/$1$is_args$args;\n}\n',
  })
);

Output:

nginx.ingress.kubernetes.io/configuration-snippet: >
  location ~*
  ^/sites/aaaaaaa.aa/files/(.+) {
    return 302 https://process.aaaaaaa.aa/sites/aaaaaaa.aa/files/$1;
  }

  location ~* ^/partner-application/cls/(.+) {
    return 301 https://process.aaaaaaa.aa/partner-application/cls/$1$is_args$args;
  }

Expected behaviour

Expected output:

nginx.ingress.kubernetes.io/configuration-snippet: >
  location ~* ^/sites/aaaaaaa.aa/files/(.+) {
    return 302 https://process.aaaaaaa.aa/sites/aaaaaaa.aa/files/$1;
  }
  location ~* ^/partner-application/cls/(.+) {
    return 301 https://process.aaaaaaa.aa/partner-application/cls/$1$is_args$args;
  }

Versions (please complete the following information):

Node:

$ node --version
v16.18.1

Yaml: 2.1.3

Note: edited and site name was redacted. I try use example.com but in this case there was expected output. Probably problem is related with long lines?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions