diff --git a/flask_weasyprint/__init__.py b/flask_weasyprint/__init__.py index 2851f73..53bd6cc 100644 --- a/flask_weasyprint/__init__.py +++ b/flask_weasyprint/__init__.py @@ -20,8 +20,9 @@ def make_flask_url_dispatcher(): has returned. Dispatch to the context’s app URLs below the context’s root URL. If the - application has a ``SERVER_NAME`` :doc:`configuration `, also - accept URLs that have that domain name or a subdomain thereof. + application has a ``SERVER_NAME`` :doc:`configuration ` and + ``subdomain_matching`` is set, also accept URLs that have that domain name + or a subdomain thereof. """ def parse_netloc(netloc): @@ -33,7 +34,7 @@ def parse_netloc(netloc): root_path = request.script_root server_name = app.config.get('SERVER_NAME') - if server_name: + if server_name and app.subdomain_matching: hostname, port = parse_netloc(server_name) def accept(url): diff --git a/tests/test_flask_weasyprint.py b/tests/test_flask_weasyprint.py index d9afdf7..3bfe5d0 100644 --- a/tests/test_flask_weasyprint.py +++ b/tests/test_flask_weasyprint.py @@ -111,7 +111,7 @@ def add_redirect(old_url, new_url): def test_dispatcher(): - app = Flask(__name__) + app = Flask(__name__, subdomain_matching=True) app.config['PROPAGATE_EXCEPTIONS'] = True @app.route('/')