Skip to content
This repository has been archived by the owner on Nov 20, 2023. It is now read-only.

Commit

Permalink
Fix nginx ingress path for capture group (#752)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotalik committed Nov 4, 2020
1 parent 907d735 commit 77ebc0d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Microsoft.Tye.Core/KubernetesManifestGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,21 @@ public static KubernetesIngressOutput CreateIngress(
//
// Therefore our rewrite-target is set to $2 - we want to make sure we have
// two capture groups.
if (string.IsNullOrEmpty(ingressRule.Path) || ingressRule.Path == "/" || ingressRule.PreservePath)
if (string.IsNullOrEmpty(ingressRule.Path) || ingressRule.Path == "/")
{
path.Add("path", "/()(.*)"); // () is an empty capture group.
}
else
{
var regex = $"{ingressRule.Path.TrimEnd('/')}(/|$)(.*)";
path.Add("path", regex);
if (ingressRule.PreservePath)
{
path.Add("path", $"/()({ingressRule.Path.Trim('/')}.*)");
}
else
{
var regex = $"{ingressRule.Path.TrimEnd('/')}(/|$)(.*)";
path.Add("path", regex);
}
}
}
}
Expand Down

0 comments on commit 77ebc0d

Please sign in to comment.