Utils: improved URL processing