parted
parted copied to clipboard
Empty strings aren't empty
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?
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.