@@ -118,3 +118,24 @@ func TestAllowlistPathMatch(t *testing.T) {
118
118
assertAllowlistMatch (t , allowlist , "GET" , "https://foo.com/variable-path/bla%2Fbla/suffix" , true )
119
119
assertAllowlistMatch (t , allowlist , "GET" , "https://foo.com/variable-path/bla/bla/suffix" , false )
120
120
}
121
+
122
+ func TestAllowlistEncodedPathMatch (t * testing.T ) {
123
+ allowlist := & Allowlist {
124
+ AllowlistItem {
125
+ URL : "https://gitlab.example.com/api/v4/projects/group%2Fproject/repository/files/*" ,
126
+ Methods : ParseHttpMethods ([]string {"GET" }),
127
+ },
128
+ AllowlistItem {
129
+ URL : "https://gitlab.example.com/api/v4/projects/:group%2F:project/repository/files/*" ,
130
+ Methods : ParseHttpMethods ([]string {"GET" }),
131
+ },
132
+ }
133
+
134
+ // Test that encoded forward slashes in the path match correctly
135
+ assertAllowlistMatch (t , allowlist , "GET" , "https://gitlab.example.com/api/v4/projects/group%2Fproject/repository/files/path/to/file" , true )
136
+ assertAllowlistMatch (t , allowlist , "GET" , "https://gitlab.example.com/api/v4/projects/group/project/repository/files/path/to/file" , false )
137
+
138
+ // Test with variables containing encoded characters
139
+ assertAllowlistMatch (t , allowlist , "GET" , "https://gitlab.example.com/api/v4/projects/test-group%2Ftest-project/repository/files/path/to/file" , true )
140
+ assertAllowlistMatch (t , allowlist , "GET" , "https://gitlab.example.com/api/v4/projects/test-group/test-project/repository/files/path/to/file" , false )
141
+ }
0 commit comments