diff --git a/CHANGES.rst b/CHANGES.rst index 88970a666..a749a2129 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -11,6 +11,7 @@ Unreleased - ``_plain_int`` and ``_plain_float`` strip whitespace before type enforcement. :issue:`2734` - Fix empty file streaming when testing. :issue:`2740` +- Clearer error message when URL rule does not start with slash. :pr:`2750` Version 2.3.6 diff --git a/src/werkzeug/routing/rules.py b/src/werkzeug/routing/rules.py index d65dce028..904a02258 100644 --- a/src/werkzeug/routing/rules.py +++ b/src/werkzeug/routing/rules.py @@ -454,7 +454,8 @@ def __init__( websocket: bool = False, ) -> None: if not string.startswith("/"): - raise ValueError("urls must start with a leading slash:", string) + raise ValueError(f"URL rule '{string}' must start with a slash.") + self.rule = string self.is_leaf = not string.endswith("/") self.is_branch = string.endswith("/")