Check URL before navigation

Fixed an error when an invalid url is given in the address bar.
Merge pull request #2044 from libm/master

Check URL before navigation