Skip to content

Commit b21b4d1

Browse files
committed
add more merge cases
1 parent f7a3bdc commit b21b4d1

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

flask/blueprints.py

Lines changed: 3 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
@@ -67,7 +66,8 @@ def add_url_rule(self, rule, endpoint=None, view_func=None, **options):
6766
"""
6867
if self.url_prefix is not None:
6968
if rule:
70-
rule = '/'.join((self.url_prefix, rule.lstrip('/')))
69+
rule = '/'.join((
70+
self.url_prefix.rstrip('/'), rule.lstrip('/')))
7171
else:
7272
rule = self.url_prefix
7373
options.setdefault('subdomain', self.subdomain)

tests/test_blueprints.py

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

117117

118118
@pytest.mark.parametrize(('prefix', 'rule', 'url'), (
119+
('', '/', '/'),
120+
('/', '', '/'),
121+
('/', '/', '/'),
119122
('/foo', '', '/foo'),
123+
('/foo/', '', '/foo/'),
124+
('', '/bar', '/bar'),
120125
('/foo/', '/bar', '/foo/bar'),
121126
('/foo/', 'bar', '/foo/bar'),
122127
('/foo', '/bar', '/foo/bar'),

0 commit comments

Comments
 (0)