Fix the trailing slash bug

Fix the "Cannot read property '1' of null" exception when a trailing slash is used after an extension.