fixed some bugs when parsing URL