Hello,
I propose the following changes to pyramid/config/routes.py:
372c372,375
< pattern = self.route_prefix.rstrip('/') + '/' + pattern.lstrip('/')
---
> if pattern:
> pattern = self.route_prefix.rstrip('/') + '/' + pattern.lstrip('/')
> else:
> pattern = self.route_prefix
Reasoning:
Take the following example:
from pyramid.config import Configurator
# maybe defined in some included application
def routes(config):
config.add_route('example', '')
# maybe the configuration of an including application
if __name__ == '__main__':
config = Configurator()
config.include(routes, route_prefix="/prefix")
This will always generate the following route:
Notice the trailing "/" in the route, although I haven't specified it in my configuration.
With the change I posted above it would be possible to define, whether the final route should have a trailing "/" or not.
It would still have a bias towards having a trailing "/" as both the including and the included application can specify one:
# included application:
config.add_route('example', '/')
# including application:
if __name__ == '__main__':
config = Configurator()
config.include(routes, route_prefix="/prefix/")
This would both result in the following route:
but the first example would have this route:
An existing trailing slash in either of the configurations wouldn't be removed and if there is none defined, it wouldn't be added. I think, that this would be the expected behavior.
Cheers,
Andreas