File tree 2 files changed +25
-2
lines changed
src/firebase_functions/private
2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -129,9 +129,10 @@ class PathPattern:
129
129
segments : list [PathSegment ]
130
130
131
131
def __init__ (self , raw_path : str ):
132
- self .raw = raw_path
132
+ normalized_path = raw_path .strip ("/" )
133
+ self .raw = normalized_path
133
134
self .segments = []
134
- self .init_path_segments (raw_path )
135
+ self .init_path_segments (normalized_path )
135
136
136
137
def init_path_segments (self , raw : str ):
137
138
parts = raw .split ("/" )
Original file line number Diff line number Diff line change @@ -41,6 +41,28 @@ def test_trim_param(self):
41
41
self .assertEqual (trim_param ("{something=*}" ), "something" )
42
42
43
43
def test_extract_matches (self ):
44
+ # parse single-capture segments with leading slash
45
+ pp = PathPattern ("/messages/{a}/{b}/{c}" )
46
+ self .assertEqual (
47
+ pp .extract_matches ("messages/match_a/match_b/match_c" ),
48
+ {
49
+ "a" : "match_a" ,
50
+ "b" : "match_b" ,
51
+ "c" : "match_c" ,
52
+ },
53
+ )
54
+
55
+ # parse single-capture segments without leading slash
56
+ pp = PathPattern ("messages/{a}/{b}/{c}" )
57
+ self .assertEqual (
58
+ pp .extract_matches ("messages/match_a/match_b/match_c" ),
59
+ {
60
+ "a" : "match_a" ,
61
+ "b" : "match_b" ,
62
+ "c" : "match_c" ,
63
+ },
64
+ )
65
+
44
66
# parse without multi-capture segments
45
67
pp = PathPattern ("{a}/something/else/{b}/end/{c}" )
46
68
self .assertEqual (
You can’t perform that action at this time.
0 commit comments