    def validate_routespec(self, routespec):
        """Validate a routespec

        - Checks host value vs host-based routing.
        - Ensures trailing slash on path.
        """
        if routespec == '/':
            # / is the default route.
            # don't check host-based routing
            return routespec
        # check host routing
        host_route = not routespec.startswith('/')
        if host_route and not self.host_routing:
            raise ValueError(
                f"Cannot add host-based route {routespec!r}, not using host-routing"
            )
        if self.host_routing and not host_route:
            raise ValueError(
                f"Cannot add route without host {routespec!r}, using host-routing"
            )
        # add trailing slash
        if not routespec.endswith('/'):
            return routespec + '/'
        else:
            return routespec
Validate a routespec

- Checks host value vs host-based routing.
- Ensures trailing slash on path.
jupyterhub/proxy.py