Skip to content

Commit 786f04f

Browse files
Adds support for special chars in URLs for OpenAPI spec matching. Closes #1050 (#1051)
1 parent 153b38e commit 786f04f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

dev-proxy-plugins/OpenApi/OpenApiDocumentExtensions.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ public static class OpenApiDocumentExtensions
4848
// and operations and sometimes, parameters are defined only
4949
// on the operation. This way, we cover all cases, and we don't
5050
// care about the parameter anyway here
51-
urlPathFromSpec = Regex.Replace(urlPathFromSpec, @"\{[^}]+\}", $"([^/]+)");
51+
// we also escape the path to make sure that regex special
52+
// characters are not interpreted so that we won't fail
53+
// on matching URLs that contain ()
54+
urlPathFromSpec = Regex.Replace(Regex.Escape(urlPathFromSpec), @"\\\{[^}]+\}", $"([^/]+)");
5255

5356
logger.LogDebug("Converted path to Regex: {urlPath}", urlPathFromSpec);
5457
var regex = new Regex($"^{urlPathFromSpec}$");

0 commit comments

Comments
 (0)