Merge branch '1.0-maintenance'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Lord · committed by David Lord · parents 35afec3, 939c77a · Browse files · 4 files·+32 added−5 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+32 added−5 removed
- tests:+6 added−0 removed
- other:+26 added−5 removed
Provenance
- Commit
9bee619- Tree
7342595- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent 1
35afec3- Parent 2
939c77a
4 files changed+32 added−5 removed
modified:flask/blueprints.py+6 added-3 removed
8 unmodified lines9 :copyright: © 2010 by the Pallets team.10 :license: BSD, see LICENSE for more details.11 """12 from functools import update_wrapper13+from werkzeug.urls import url_join14 15 from .helpers import _PackageBoundObject, _endpoint_from_view_func16 17 31 unmodified lines49 50 url_prefix = self.options.get('url_prefix')51 if url_prefix is None:52 url_prefix = self.blueprint.url_prefix52- if url_prefix:53- url_prefix = url_prefix.rstrip('/')53 #: The prefix that should be used for all URLs defined on the54 #: blueprint.55 self.url_prefix = url_prefix56 7 unmodified lines64 to the application. The endpoint is automatically prefixed with the65 blueprint's name.66 """67 if self.url_prefix is not None:69- rule = '/'.join((self.url_prefix, rule.lstrip('/')))68+ if rule:69+ rule = '/'.join((70+ self.url_prefix.rstrip('/'), rule.lstrip('/')))71+ else:72+ rule = self.url_prefix73 options.setdefault('subdomain', self.subdomain)74 if endpoint is None:75 endpoint = _endpoint_from_view_func(view_func)76 defaults = self.url_defaults372 unmodified linesmodified:flask/cli.py+4 added
823 unmodified lines824 def routes_command(sort, all_methods):825 """Show all registered routes with endpoints and methods."""826 827 rules = list(current_app.url_map.iter_rules())828+ if not rules:829+ click.echo('No routes were registered.')830+ return831+832 ignored_methods = set(() if all_methods else ('HEAD', 'OPTIONS'))833 834 if sort in ('endpoint', 'rule'):835 rules = sorted(rules, key=attrgetter(sort))63 unmodified linesmodified:tests/test_blueprints.py+6 added
114 unmodified lines115 assert client.get('/nope').data == b'you shall not pass'116 117 118 @pytest.mark.parametrize(('prefix', 'rule', 'url'), (119+ ('', '/', '/'),120+ ('/', '', '/'),121+ ('/', '/', '/'),122+ ('/foo', '', '/foo'),123+ ('/foo/', '', '/foo/'),124+ ('', '/bar', '/bar'),125 ('/foo/', '/bar', '/foo/bar'),126 ('/foo/', 'bar', '/foo/bar'),127 ('/foo', '/bar', '/foo/bar'),128 ('/foo/', '//bar', '/foo/bar'),728 unmodified linesmodified:CHANGES.rst+16 added-2 removed
8 unmodified lines9 10 Unreleased11 12 13-Version 1.0.213+Version 1.0.314 -------------15 16 Unreleased17 18 19+Version 1.0.220+-------------21+22+Released on May 2nd 201823+24+- Fix more backwards compatibility issues with merging slashes between25+ a blueprint prefix and route. (`#2748`_)26+- Fix error with ``flask routes`` command when there are no routes.27+ (`#2751`_)28+29+.. _#2748: https://github.com/pallets/flask/pull/274830+.. _#2751: https://github.com/pallets/flask/issues/275131+32+33 Version 1.0.134 -------------35 22-Released on April 29 201836+Released on April 29th 201837 38 - Fix registering partials (with no ``__name__``) as view functions.39 (`#2730`_)40 - Don't treat lists returned from view functions the same as tuples.876 unmodified lines