fix js substring / ruby .. off by one error