Merge pull request #925 from wpreul/master

Fixing edge case where bad path can cause issues with url.parse
Removing global variable