Fix query url creation logic.