Fix a javascript error when `input` is an integer (substr func is only for strings)