diff --git a/src/calibre/srv/routes.py b/src/calibre/srv/routes.py index 4e381b163c..ce77f19000 100644 --- a/src/calibre/srv/routes.py +++ b/src/calibre/srv/routes.py @@ -290,5 +290,7 @@ class Router(object): return ans def url_for(self, route, **kwargs): + if route is None: + return self.url_prefix or '/' route = getattr(route, 'route_key', route) return self.url_prefix + self.routes[route].url_for(**kwargs) diff --git a/src/calibre/srv/tests/routes.py b/src/calibre/srv/tests/routes.py index 722cb929ff..8f50f10d95 100644 --- a/src/calibre/srv/tests/routes.py +++ b/src/calibre/srv/tests/routes.py @@ -97,3 +97,4 @@ class TestRouter(BaseTest): self.ae(ep, soak_opt), self.ae(args, ['a/b']) self.ae(router.url_for('/needs quoting', x='a/b c'), '/needs quoting/a%2Fb%20c') + self.ae(router.url_for(None), '/')