Skip to content

sanitize removes brackets that it should not #21

@wenottingham

Description

@wenottingham

Describe the problem

When the ANSI sequence is directly wrapped in brackets the brackets are removed from the output.

Steps to reproduce the problem

require 'strings-ansi'

str1 = "[\e[1;34mINFO\e[m] Scanning for projects..."
str2 = "[ \e[1;34mINFO\e[m ] Scanning for projects..."
puts str1
puts str2
puts Strings::ANSI.sanitize(str1)
puts Strings::ANSI.sanitize(str2)

Actual behaviour

[INFO] Scanning for projects...
[ INFO ] Scanning for projects...
INFO Scanning for projects...
[ INFO ] Scanning for projects...

Expected behaviour

[INFO] Scanning for projects...
[ INFO ] Scanning for projects...
[INFO] Scanning for projects...
[ INFO ] Scanning for projects...

Describe your environment

  • OS version: Linux (Fedora 38)
  • Ruby version: 3.1.4
  • strings (0.2.1)
  • strings-ansi (0.2.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions