Let’s say there is a REST API which allows users to create objects. These objects have a name. The name doesn’t need to be unique among all objects and doesn’t have any special meaning within the API. Should the API strip whitespace before creating the object?
Pro stripping
- Most of the time whitespace (at least leading and trailing) is unintentional
- It’s not visible anyway on a web interface (unless explicitly displayed as nbsp)
Contra stripping
- It’s wrong to modify user data
- An API is a programming interface, expect input to really be what the user wants