File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -138,7 +138,12 @@ def _func(data: dict[str, Any]) -> str:
138138
139139
140140def get_file_name_strip_func (strip_prefix : str ) -> Callable :
141+ strip_prefix = strip_prefix .strip ("/" )
142+
141143 def _func (data : dict [str , Any ]) -> str :
142- return get_file_key (data )[len (strip_prefix ) :].strip ("/" )
144+ key = get_file_key (data )
145+ if key .startswith (strip_prefix ):
146+ key = key [len (strip_prefix ) :].strip ("/" )
147+ return key
143148
144149 return _func
Original file line number Diff line number Diff line change @@ -68,4 +68,8 @@ def get_key(data):
6868 get_file_name_strip_func ("en/request" )(data )
6969 == "14928/response/55317/attach/5/Communication from the Commission SG 2009 D 51604.pdf"
7070 )
71+ assert (
72+ get_file_name_strip_func ("foo/bar" )(data )
73+ == "en/request/14928/response/55317/attach/5/Communication from the Commission SG 2009 D 51604.pdf"
74+ )
7175 assert get_file_name_templ_func ("{{ headers.Server }}.pdf" )(data ) == "nginx.pdf"
You can’t perform that action at this time.
0 commit comments