bug #4499 Uncaught TypeError: Cannot call method 'substr' of undefined

Signed-off-by: Marc Delisle <marc@infomarc.info>