From abfa1beade76b42782a9790250febce0ab6117d7 Mon Sep 17 00:00:00 2001 From: Arthur Darcet Date: Mon, 7 Nov 2016 15:30:16 +0100 Subject: [PATCH] allow starting variables with an underscore Mongo ids are useful as a named resource in a route, but they are usually named `_id` and are excluded by the current regex --- aiohttp/web_urldispatcher.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aiohttp/web_urldispatcher.py b/aiohttp/web_urldispatcher.py index a701156707a..713d58aecdd 100644 --- a/aiohttp/web_urldispatcher.py +++ b/aiohttp/web_urldispatcher.py @@ -694,12 +694,12 @@ def __contains__(self, route): class UrlDispatcher(AbstractRouter, collections.abc.Mapping): - DYN = re.compile(r'\{(?P[a-zA-Z][_a-zA-Z0-9]*)\}') + DYN = re.compile(r'\{(?P[_a-zA-Z][_a-zA-Z0-9]*)\}') DYN_WITH_RE = re.compile( - r'\{(?P[a-zA-Z][_a-zA-Z0-9]*):(?P.+)\}') + r'\{(?P[_a-zA-Z][_a-zA-Z0-9]*):(?P.+)\}') GOOD = r'[^{}/]+' ROUTE_RE = re.compile(r'(\{[_a-zA-Z][^{}]*(?:\{[^{}]*\}[^{}]*)*\})') - NAME_SPLIT_RE = re.compile('[.:-]') + NAME_SPLIT_RE = re.compile(r'[.:-]') def __init__(self, app): super().__init__()