fent/irc-colors.js

Certain strings can cause undesired output

HigherFive opened this issue · 5 comments

For example, ',1 cheeky hack'.irc.blue() would return '\u000312,1 cheeky hack\u0003'.

I couldn't find a standard solution to this on the web, but using the zero width space character \u200b seems to do the trick.

fent commented

Using it before the string?

Yes, as in returning something like '\u000312\u200b,1 cheeky hack\u0003' when no bg color is specified.

Thanks for readily implementing this, but I was half-hoping for you to slap me and tell me of "the proper solution" to this. Adding a "non-standard" character like this doesn't seem like a good idea to me.

After considering it further, I think that any sanitizing of the input is better left up to the user.

fent commented

I seem to be easy to convince

other solution would be to add a transparent bg color, I didn't look into it though.

What was the "undesired output" in this scenario? ',1 cheeky hack'.irc.blue() should return '\u000312,1 cheeky hack\u0003', shouldn't it?