A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/encode/starlette/issues/633 below:

Strip trailing slash ( / ) from URL route strings. · Issue #633 · encode/starlette · GitHub

Hey all, an optional trailing slash seems to be pretty standard on most websites, but in Starlette, you must add separate routes to handle them. Example:

routes = [
    Route('/', PlainTextResponse("home")),
    Route('/test', PlainTextResponse("test")),
    Route('/test/', PlainTextResponse("I need to be added separately?!"))
]

app = Starlette(routes=routes)

Could a route = route.rstrip("/") please be added to https://github.com/encode/starlette/blob/master/starlette/routing.py in class Router before running the match so these routes don't have to be manually added? Thanks!


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4