Ensure httproute rule match is only of type PathPrefix

This commit is contained in:
djeinstine
2025-02-01 17:28:01 +00:00
parent 1bbbcfda69
commit c4f2c87e57

View File

@@ -56,10 +56,12 @@ async function getUrlFromHttpRoute(ingress) {
let url = null
if (ingress.spec.has("hostnames")) {
const urlHost = ingress.spec.hostnames[0];
const urlPath = ingress.spec.rules[0].matches[0].path.value;
const urlSchema = (await getSchemaFromGateway(ingress.spec.parentRefs[0])) ? "https" : "http";
url = `${urlSchema}://${urlHost}${urlPath}`;
if (ingress.spec.rules[0].matches[0].path.type=="PathPrefix"){
const urlHost = ingress.spec.hostnames[0];
const urlPath = ingress.spec.rules[0].matches[0].path.value;
const urlSchema = (await getSchemaFromGateway(ingress.spec.parentRefs[0])) ? "https" : "http";
url = `${urlSchema}://${urlHost}${urlPath}`;
}
}
return url;
}