Javascript route matching in 50 lines