Fix endswidth function in Chrome