piotrmurach / strings

A set of useful functions for transforming strings.
MIT License
129 stars 12 forks source link

sanitize removes brackets that it should not #21

Open wenottingham opened 1 year ago

wenottingham commented 1 year ago

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