Skip to content

Commit 9bee619

Browse files
committed
Merge branch '1.0-maintenance'
2 parents 35afec3 + 939c77a commit 9bee619

File tree

4 files changed

+32
-5
lines changed

4 files changed

+32
-5
lines changed

CHANGES.rst

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,30 @@ Version 1.1
1010
Unreleased
1111

1212

13-
Version 1.0.2
13+
Version 1.0.3
1414
-------------
1515

1616
Unreleased
1717

1818

19+
Version 1.0.2
20+
-------------
21+
22+
Released on May 2nd 2018
23+
24+
- Fix more backwards compatibility issues with merging slashes between
25+
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/2748
30+
.. _#2751: https://github.com/pallets/flask/issues/2751
31+
32+
1933
Version 1.0.1
2034
-------------
2135

22-
Released on April 29 2018
36+
Released on April 29th 2018
2337

2438
- Fix registering partials (with no ``__name__``) as view functions.
2539
(`#2730`_)

flask/blueprints.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
:license: BSD, see LICENSE for more details.
1111
"""
1212
from functools import update_wrapper
13+
from werkzeug.urls import url_join
1314

1415
from .helpers import _PackageBoundObject, _endpoint_from_view_func
1516

@@ -49,8 +50,6 @@ def __init__(self, blueprint, app, options, first_registration):
4950
url_prefix = self.options.get('url_prefix')
5051
if url_prefix is None:
5152
url_prefix = self.blueprint.url_prefix
52-
if url_prefix:
53-
url_prefix = url_prefix.rstrip('/')
5453
#: The prefix that should be used for all URLs defined on the
5554
#: blueprint.
5655
self.url_prefix = url_prefix
@@ -66,7 +65,11 @@ def add_url_rule(self, rule, endpoint=None, view_func=None, **options):
6665
blueprint's name.
6766
"""
6867
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_prefix
7073
options.setdefault('subdomain', self.subdomain)
7174
if endpoint is None:
7275
endpoint = _endpoint_from_view_func(view_func)

flask/cli.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,10 @@ def routes_command(sort, all_methods):
825825
"""Show all registered routes with endpoints and methods."""
826826

827827
rules = list(current_app.url_map.iter_rules())
828+
if not rules:
829+
click.echo('No routes were registered.')
830+
return
831+
828832
ignored_methods = set(() if all_methods else ('HEAD', 'OPTIONS'))
829833

830834
if sort in ('endpoint', 'rule'):

tests/test_blueprints.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ def bp_forbidden():
116116

117117

118118
@pytest.mark.parametrize(('prefix', 'rule', 'url'), (
119+
('', '/', '/'),
120+
('/', '', '/'),
121+
('/', '/', '/'),
122+
('/foo', '', '/foo'),
123+
('/foo/', '', '/foo/'),
124+
('', '/bar', '/bar'),
119125
('/foo/', '/bar', '/foo/bar'),
120126
('/foo/', 'bar', '/foo/bar'),
121127
('/foo', '/bar', '/foo/bar'),

0 commit comments

Comments
 (0)