Fixing a bug introduced in the latest commits.

Not all browsers implement String.endsWith, so we better use a different
testing method instead.