parent
3dc6db9d0c
commit
8368872ccd
3 changed files with 32 additions and 0 deletions
|
|
@ -9,6 +9,8 @@ Version 2.2.3
|
|||
|
||||
Unreleased
|
||||
|
||||
- Fix subdomain inheritance for nested blueprints. :issue:`4834`
|
||||
|
||||
|
||||
Version 2.2.2
|
||||
-------------
|
||||
|
|
|
|||
|
|
@ -453,6 +453,15 @@ class Blueprint(Scaffold):
|
|||
for blueprint, bp_options in self._blueprints:
|
||||
bp_options = bp_options.copy()
|
||||
bp_url_prefix = bp_options.get("url_prefix")
|
||||
bp_subdomain = bp_options.get("subdomain")
|
||||
|
||||
if bp_subdomain is None:
|
||||
bp_subdomain = blueprint.subdomain
|
||||
|
||||
if state.subdomain is not None and bp_subdomain is None:
|
||||
bp_options["subdomain"] = state.subdomain
|
||||
elif bp_subdomain is not None:
|
||||
bp_options["subdomain"] = bp_subdomain
|
||||
|
||||
if bp_url_prefix is None:
|
||||
bp_url_prefix = blueprint.url_prefix
|
||||
|
|
|
|||
|
|
@ -950,6 +950,27 @@ def test_nesting_url_prefixes(
|
|||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_nesting_subdomains(app, client) -> None:
|
||||
subdomain = "api"
|
||||
parent = flask.Blueprint("parent", __name__)
|
||||
child = flask.Blueprint("child", __name__)
|
||||
|
||||
@child.route("/child/")
|
||||
def index():
|
||||
return "child"
|
||||
|
||||
parent.register_blueprint(child)
|
||||
app.register_blueprint(parent, subdomain=subdomain)
|
||||
|
||||
client.allow_subdomain_redirects = True
|
||||
|
||||
domain_name = "domain.tld"
|
||||
app.config["SERVER_NAME"] = domain_name
|
||||
response = client.get("/child/", base_url="http://api." + domain_name)
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
def test_unique_blueprint_names(app, client) -> None:
|
||||
bp = flask.Blueprint("bp", __name__)
|
||||
bp2 = flask.Blueprint("bp", __name__)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue