forked from orbit-oss/flask
Do not enable subdomain matching by default
Updated tests for new subdomain matching Added a test to validate matching behavior
This commit is contained in:
parent
4a7db66474
commit
8cec2010c0
4 changed files with 52 additions and 7 deletions
16
flask/app.py
16
flask/app.py
|
|
@ -126,6 +126,11 @@ class Flask(_PackageBoundObject):
|
|||
.. versionadded:: 0.13
|
||||
The `host_matching` and `static_host` parameters were added.
|
||||
|
||||
.. versionadded:: 1.0
|
||||
The `subdomain_matching` parameter was added. Subdomain matching
|
||||
needs to be enabled manually now. Setting `SERVER_NAME` does not
|
||||
implicitly enable it.
|
||||
|
||||
:param import_name: the name of the application package
|
||||
:param static_url_path: can be used to specify a different path for the
|
||||
static files on the web. Defaults to the name
|
||||
|
|
@ -347,6 +352,7 @@ class Flask(_PackageBoundObject):
|
|||
static_folder='static',
|
||||
static_host=None,
|
||||
host_matching=False,
|
||||
subdomain_matching=False,
|
||||
template_folder='templates',
|
||||
instance_path=None,
|
||||
instance_relative_config=False,
|
||||
|
|
@ -530,6 +536,7 @@ class Flask(_PackageBoundObject):
|
|||
self.url_map = Map()
|
||||
|
||||
self.url_map.host_matching = host_matching
|
||||
self.subdomain_matching = subdomain_matching
|
||||
|
||||
# tracks internally if the application already handled at least one
|
||||
# request.
|
||||
|
|
@ -1988,8 +1995,15 @@ class Flask(_PackageBoundObject):
|
|||
URL adapter is created for the application context.
|
||||
"""
|
||||
if request is not None:
|
||||
return self.url_map.bind_to_environ(request.environ,
|
||||
rv = self.url_map.bind_to_environ(request.environ,
|
||||
server_name=self.config['SERVER_NAME'])
|
||||
# If subdomain matching is not enabled (which is the default
|
||||
# we put back the default subdomain in all cases. This really
|
||||
# should be the default in Werkzeug but it currently does not
|
||||
# have that feature.
|
||||
if not self.subdomain_matching:
|
||||
rv.subdomain = self.url_map.default_subdomain
|
||||
return rv
|
||||
# We need at the very least the server name to be set for this
|
||||
# to work.
|
||||
if self.config['SERVER_NAME'] is not None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue