Skip to content
Myr

Merge pull request #3182 from qil026/issue-3134-url-join

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

Remove ending slash from static_url_path

authored by David Lord · committed by GitHub · parents 7f98a28, 2039e2e · Browse files · 4 files+15 added−2 removed
This commit

State

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

Diff stats

4 files+15 added−2 removed

  • tests:+11 added−0 removed
  • other:+4 added−2 removed

4 files+15 added−2 removed

modified:flask/app.py+1 added-1 removed
585 unmodified lines
586 assert (587 bool(static_host) == host_matching588 ), "Invalid static_host/host_matching combination"589 self.add_url_rule(590 self.static_url_path + "/<path:filename>",590 self.static_url_path.rstrip("/") + "/<path:filename>",591 endpoint="static",592 host=static_host,593 view_func=self.send_static_file,594 )
1813 unmodified lines
modified:flask/blueprints.py+1 added-1 removed
196 unmodified lines
197 state = self.make_setup_state(app, options, first_registration)198199 if self.has_static_folder:200 state.add_url_rule(201 self.static_url_path + "/<path:filename>",201 self.static_url_path.rstrip("/") + "/<path:filename>",202 view_func=self.send_static_file,203 endpoint="static",204 )205
301 unmodified lines
modified:tests/test_basic.py+11 added
1397 unmodified lines
1398 with app.test_request_context():1399 assert flask.url_for("static", filename="index.html") == "/foo/index.html"140014011402def test_static_url_path_with_ending_slash():1403 app = flask.Flask(__name__, static_url_path="/foo/")1404 app.testing = True1405 rv = app.test_client().get("/foo/index.html")1406 assert rv.status_code == 2001407 rv.close()14081409 with app.test_request_context():1410 assert flask.url_for("static", filename="index.html") == "/foo/index.html"141114121413def test_static_route_with_host_matching():1414 app = flask.Flask(__name__, host_matching=True, static_host="example.com")1415 c = app.test_client()1416 rv = c.get("http://example.com/static/index.html")
539 unmodified lines
modified:CHANGES.rst+2 added
34 unmodified lines
35 :issue:`3125`36- The ``flask`` command entry point is simplified to take advantage37 of Werkzeug 0.15's better reloader support. This bumps the Werkzeug38 dependency to >= 0.15. :issue:`3022`39- Support ``static_url_path`` that ends with a forward slash.40 :issue:`3134`4142.. _#2935: https://github.com/pallets/flask/issues/293543.. _#2957: https://github.com/pallets/flask/issues/295744.. _#2994: https://github.com/pallets/flask/pull/2994
948 unmodified lines