@@ -44,8 +44,8 @@ def request_params(req):
4444 return values_dict (params .lists ())
4545
4646
47- NP_REGEXP = re .compile (r"<Rule '(.*?)'" )
48- NP_XLATE = re . compile ( r"(?P<l><)|(?P<r>>) " )
47+ NP_PARAMS = re .compile (r"<Rule '(.*?)'" )
48+ NP_PARAM_DELIMS = str . maketrans ( "<>" , "{} " )
4949
5050
5151class AppmapFlask (AppmapMiddleware ):
@@ -93,15 +93,12 @@ def before_request_main(self, rec, request):
9393 # Transform request.url to the expected normalized-path form. For example,
9494 # "/post/<username>/<post_id>/summary" becomes "/post/{username}/{post_id}/summary".
9595 # Notes:
96- # * the value of `repr` of this rule begins with "<Repr '/post/<username>/<post_id>/summary'"
96+ # * the value of `repr` of this rule begins with "<Rule '/post/<username>/<post_id>/summary'"
9797 # * the variable names in a rule can only contain alphanumerics:
9898 # * flask 1: https://github.com/pallets/werkzeug/blob/1dde4b1790f9c46b7122bb8225e6b48a5b22a615/src/werkzeug/routing.py#L143
9999 # * flask 2: https://github.com/pallets/werkzeug/blob/99f328cf2721e913bd8a3128a9cdd95ca97c334c/src/werkzeug/routing/rules.py#L56
100100 r = repr (request .url_rule )
101- np = NP_XLATE .sub (
102- lambda m : "{" if m ["l" ] else "}" if m ["r" ] else "" ,
103- NP_REGEXP .findall (r )[0 ],
104- )
101+ np = NP_PARAMS .findall (r )[0 ].translate (NP_PARAM_DELIMS )
105102
106103 call_event = HttpServerRequestEvent (
107104 request_method = request .method ,
0 commit comments