improved url parsing to ignore text after ? or #