Skip to content
Myr

Merge pull request #2748 from pallets/fix-bp-route

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

Fix blueprint route for ""

authored by David Lord · committed by GitHub · parents 3fd7abe, b21b4d1 · Browse files · 2 files+12 added−3 removed
This commit

State

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

Diff stats

2 files+12 added−3 removed

  • tests:+6 added−0 removed
  • other:+6 added−3 removed

2 files+12 added−3 removed

modified:flask/blueprints.py+6 added-3 removed
8 unmodified lines
9 :copyright: © 2010 by the Pallets team.10 :license: BSD, see LICENSE for more details.11"""12from functools import update_wrapper13from werkzeug.urls import url_join1415from .helpers import _PackageBoundObject, _endpoint_from_view_func1617
31 unmodified lines
4950 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 lines
64 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_defaults
372 unmodified lines
modified:tests/test_blueprints.py+6 added
114 unmodified lines
115 assert client.get('/nope').data == b'you shall not pass'116117118@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 lines