Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce unique route names #2641

Open
1 task done
ahopkins opened this issue Dec 25, 2022 · 1 comment
Open
1 task done

Enforce unique route names #2641

ahopkins opened this issue Dec 25, 2022 · 1 comment
Milestone

Comments

@ahopkins
Copy link
Member

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe.

No response

Describe the solution you'd like

In v23.3 we will begin enforcing unique route names. We will need to force routes with multiple hosts to have a unique name with something like this:

diff --git a/sanic/router.py b/sanic/router.py
index b68fde3b..b2e0fc69 100644
--- a/sanic/router.py
+++ b/sanic/router.py
@@ -139,6 +139,9 @@ class Router(BaseRouter):
             route.extra.static = static
             route.extra.error_format = error_format
 
+            if len(hosts) > 1 and host:
+                route.name = f"{route.name}__host_{host.replace('.', '_')}"
+
             if error_format:
                 check_error_format(route.extra.error_format)

Additional context

No response

@ahopkins ahopkins added this to the 23.3 milestone Dec 25, 2022
@ChihweiLHBird
Copy link
Member

Was this added in 23.3?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants