mirror of https://github.com/pallets/flask.git
strip the ending slash for static_url_path
This commit is contained in:
parent
ef27c1b749
commit
d4076cf07c
|
|
@ -7,6 +7,8 @@ Unreleased
|
|||
|
||||
- Work around an issue when running the ``flask`` command with an
|
||||
external debugger on Windows. :issue:`3297`
|
||||
- The static route will not catch all URLs if the ``Flask``
|
||||
``static_folder`` argument ends with a slash. :issue:`3452`
|
||||
|
||||
|
||||
Version 1.1.1
|
||||
|
|
|
|||
|
|
@ -1013,7 +1013,7 @@ class _PackageBoundObject(object):
|
|||
return self._static_url_path
|
||||
|
||||
if self.static_folder is not None:
|
||||
basename = os.path.basename(self.static_folder)
|
||||
basename = os.path.basename(self.static_folder.rstrip("/"))
|
||||
return ("/" + basename).rstrip("/")
|
||||
|
||||
@static_url_path.setter
|
||||
|
|
|
|||
|
|
@ -1425,6 +1425,17 @@ def test_static_url_empty_path_default(app):
|
|||
rv.close()
|
||||
|
||||
|
||||
def test_static_folder_with_ending_slash():
|
||||
app = flask.Flask(__name__, static_folder="static/")
|
||||
|
||||
@app.route("/<path:path>")
|
||||
def catch_all(path):
|
||||
return path
|
||||
|
||||
rv = app.test_client().get("/catch/all")
|
||||
assert rv.data == b"catch/all"
|
||||
|
||||
|
||||
def test_static_route_with_host_matching():
|
||||
app = flask.Flask(__name__, host_matching=True, static_host="example.com")
|
||||
c = app.test_client()
|
||||
|
|
|
|||
Loading…
Reference in New Issue