parted icon indicating copy to clipboard operation
parted copied to clipboard

Empty strings aren't empty

Open skysteve opened this issue 9 years ago • 1 comments

Hi can you explain the logic here please because I'm very confused and it's taken ages to actually get to the bottom of the problem.

in /lib/json.js L241 (below)

if (!this.value) this.value = ' ';

empty strings get created as " " rather than "" which means when you come to do something like

if (!req.body.stringAttr) {
   req.body.stringAttr = 'default'
}

the block doesn't match because instead of being empty, the value is " ". Perhaps I'm missing something. The fact it says "// hack for empty strings" above it suggests it's done on purpose so why?

skysteve avatar Mar 10 '15 13:03 skysteve

I'm curious about this too, as the appearance of spaces for what were expected to be submitted empty form fields was a surprise that we didn't expect to need to deal with.

tdous avatar Mar 12 '15 08:03 tdous