Skip to content
Myr

Merge pull request #2629 from zcchen/master

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

prevent double slash /a//b when blueprint prefix ends with slash

authored by David Lord · committed by GitHub · parents f808c20, 401423d · Browse files · 3 files+20 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

3 files+20 added−2 removed

  • tests:+14 added−1 removed
  • other:+6 added−1 removed

3 files+20 added−2 removed

modified:flask/blueprints.py+3 added-1 removed
7 unmodified lines
89 :copyright: © 2010 by the Pallets team.10 :license: BSD, see LICENSE for more details.11"""1212from functools import update_wrapper1314from .helpers import _PackageBoundObject, _endpoint_from_view_func15
35 unmodified lines
51 url_prefix = self.blueprint.url_prefix5253 #: The prefix that should be used for all URLs defined on the54 #: blueprint.55 if url_prefix and url_prefix[-1] == '/':56 url_prefix = url_prefix[:-1]5758 self.url_prefix = url_prefix5960 #: A dictionary with URL defaults that is added to each and every61 #: URL that was defined with the blueprint.
386 unmodified lines
modified:tests/test_blueprints.py+14 added-1 removed
112 unmodified lines
113 assert client.get('/forbidden').data == b'you shall not pass'114 assert client.get('/nope').data == b'you shall not pass'115116117def test_blueprint_url_definitions(app, client):117def test_blueprint_prefix_slash(app, client):118 bp = flask.Blueprint('test', __name__, url_prefix='/bar/')119120 @bp.route('/foo')121 def foo():122 return '', 204123124 app.register_blueprint(bp)125 app.register_blueprint(bp, url_prefix='/spam/')126 assert client.get('/bar/foo').status_code == 204127 assert client.get('/spam/foo').status_code == 204128129130def test_blueprint_url_defaults(app, client):131 bp = flask.Blueprint('test', __name__)132133 @bp.route('/foo', defaults={'baz': 42})134 def foo(bar, baz):
708 unmodified lines
modified:CHANGES.rst+3 added
141 unmodified lines
142- Subdomain matching is disabled by default and setting143 :data:`SERVER_NAME` does not implicily enable it. It can be enabled by144 passing ``subdomain_matching=True`` to the ``Flask`` constructor.145 (`#2635`_)146- A single trailing slash is stripped from the blueprint ``url_prefix``147 when it is registered with the app. (`#2629`_)148149.. _pallets/meta#24: https://github.com/pallets/meta/issues/24150.. _#1421: https://github.com/pallets/flask/issues/1421151.. _#1489: https://github.com/pallets/flask/pull/1489
35 unmodified lines
187.. _#2606: https://github.com/pallets/flask/pull/2606188.. _#2607: https://github.com/pallets/flask/pull/2607189.. _#2636: https://github.com/pallets/flask/pull/2636190.. _#2635: https://github.com/pallets/flask/pull/2635191.. _#2629: https://github.com/pallets/flask/pull/2629192193194Version 0.12.2195--------------
618 unmodified lines