Skip to content
Myr

strip the ending slash for static_url_path

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by frostming · committed by David Lord · parent ef27c1b · Browse files · 3 files+14 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+14 added−1 removed

  • tests:+11 added−0 removed
  • other:+3 added−1 removed

3 files+14 added−1 removed

modified:src/flask/helpers.py+1 added-1 removed
1011 unmodified lines
1012 if self._static_url_path is not None:1013 return self._static_url_path10141015 if self.static_folder is not None:1016 basename = os.path.basename(self.static_folder)1016 basename = os.path.basename(self.static_folder.rstrip("/"))1017 return ("/" + basename).rstrip("/")10181019 @static_url_path.setter1020 def static_url_path(self, value):
133 unmodified lines
modified:tests/test_basic.py+11 added
1423 unmodified lines
1424 assert rv.status_code == 2001425 rv.close()142614271428def test_static_folder_with_ending_slash():1429 app = flask.Flask(__name__, static_folder="static/")14301431 @app.route("/<path:path>")1432 def catch_all(path):1433 return path14341435 rv = app.test_client().get("/catch/all")1436 assert rv.data == b"catch/all"143714381439def test_static_route_with_host_matching():1440 app = flask.Flask(__name__, host_matching=True, static_host="example.com")1441 c = app.test_client()1442 rv = c.get("http://example.com/static/index.html")
536 unmodified lines
modified:CHANGES.rst+2 added
5 unmodified lines
6Unreleased78- Work around an issue when running the ``flask`` command with an9 external debugger on Windows. :issue:`3297`10- The static route will not catch all URLs if the ``Flask``11 ``static_folder`` argument ends with a slash. :issue:`3452`121314Version 1.1.115-------------
1003 unmodified lines