Refactor out route utilities so we can reuse them in Brackets UI

@dangoor