From 21663c7cd6f3357b739707fae20ef403eae05858 Mon Sep 17 00:00:00 2001 From: awol2005ex Date: Thu, 23 Jan 2025 11:37:10 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fixed:=20=E4=BF=AE=E6=AD=A3ingress=20search?= =?UTF-8?q?=20=E9=A1=B5=E9=9D=A2=E4=B8=ADurl=E6=A3=80=E9=AA=8C=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E9=94=99=E8=AF=AF=E5=92=8Cservice=EF=BC=8Cpod?= =?UTF-8?q?=E4=B9=8B=E9=97=B4=E7=9A=84=E8=BF=9E=E6=8E=A5=E7=BA=BF=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../network/ingresses/ingress-search.vue | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/web/dashboard/src/business/network/ingresses/ingress-search.vue b/web/dashboard/src/business/network/ingresses/ingress-search.vue index bb7ccd34..fb3f832f 100644 --- a/web/dashboard/src/business/network/ingresses/ingress-search.vue +++ b/web/dashboard/src/business/network/ingresses/ingress-search.vue @@ -53,9 +53,9 @@ export default { var map = {} var result = [] lines.forEach(m => { - if (!map[m.targte + "-" + m.source]) { + if (!map[m.target + "-" + m.source]) { result.push(m) - map[m.targte + "-" + m.source] = true + map[m.target + "-" + m.source] = true } }) return result @@ -159,7 +159,12 @@ export default { if (document.getElementById("ingress-search-charts") == null) { return } - if (!this.search_url && !this.search_url.startsWith("http")) { + if (!this.search_url || this.search_url ==""){ + this.$message.error("please input the url for ingress search") + return + } + if (!this.search_url || !this.search_url.startsWith("http")) { + this.$message.error("url is invalid") return } this.loading = true @@ -193,14 +198,27 @@ export default { for (var k = 0; k < rule.http.paths.length; k++) { var path = rule.http.paths[k] + if (!this.search_url.endsWith("/")) { + if ((this.search_url+"/").startsWith("https://" + rule.host + path.path)) { + is_same_path = true + break + } + } if (this.search_url.startsWith("https://" + rule.host + path.path)) { is_same_path = true break } + } } else { for (var k = 0; k < rule.http.paths.length; k++) { var path = rule.http.paths[k] + if (!this.search_url.endsWith("/")) { + if ((this.search_url+"/").startsWith("http://" + rule.host + path.path)) { + is_same_path = true + break + } + } if (this.search_url.startsWith("http://" + rule.host + path.path)) { is_same_path = true break From bfdbff08d872b19d4ed425516f92dd365207196b Mon Sep 17 00:00:00 2001 From: awol2005ex Date: Wed, 5 Feb 2025 15:37:06 +0800 Subject: [PATCH 2/3] =?UTF-8?q?ingress=20search=20=E5=8C=B9=E9=85=8Durl=20?= =?UTF-8?q?bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../network/ingresses/ingress-search.vue | 62 +++++++++++-------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/web/dashboard/src/business/network/ingresses/ingress-search.vue b/web/dashboard/src/business/network/ingresses/ingress-search.vue index fb3f832f..d1a1ff4d 100644 --- a/web/dashboard/src/business/network/ingresses/ingress-search.vue +++ b/web/dashboard/src/business/network/ingresses/ingress-search.vue @@ -155,6 +155,40 @@ export default { } return { linkDataArray: linkDataArray, nodes: nodes, podsNodes: podsNodes } }, + toEnd(s) { + const str = s || ""; + if (str.endsWith("/")) { + return str; + } else { + return str + "/"; + } + }, + matchUrl(ingress, url,host ,path,pathType) { + + let urlForMatch =""; + if (ingress.spec.tls != null && ingress.spec.tls.length > 0) { + urlForMatch=urlForMatch+"https://"+host+path; + } else { + urlForMatch=urlForMatch+"http://"+host+path; + } + if(pathType == "Prefix"){ + return this.toEnd(url).startsWith(this.toEnd(urlForMatch)) + } else if(pathType == "Exact"){ + return this.toEnd(url) == this.toEnd(urlForMatch) + } else if(pathType == "ImplementationSpecific"){ + if(this.toEnd(url).startsWith(this.toEnd(urlForMatch))){ + return true + } else { + if(this.toEnd(url).match(this.toEnd(urlForMatch))){ + return true + } else { + return false + } + } + } else { + return this.toEnd(url).startsWith(this.toEnd(urlForMatch)) + } + }, async renderCharts() { if (document.getElementById("ingress-search-charts") == null) { return @@ -194,36 +228,14 @@ export default { if (rule.host == search_host) { is_same_domain = true - if (ingress.spec.tls != null && ingress.spec.tls.length > 0) { - - for (var k = 0; k < rule.http.paths.length; k++) { + for (var k = 0; k < rule.http.paths.length; k++) { var path = rule.http.paths[k] - if (!this.search_url.endsWith("/")) { - if ((this.search_url+"/").startsWith("https://" + rule.host + path.path)) { - is_same_path = true - break - } - } - if (this.search_url.startsWith("https://" + rule.host + path.path)) { - is_same_path = true - break - } - } - } else { - for (var k = 0; k < rule.http.paths.length; k++) { - var path = rule.http.paths[k] - if (!this.search_url.endsWith("/")) { - if ((this.search_url+"/").startsWith("http://" + rule.host + path.path)) { - is_same_path = true - break - } - } - if (this.search_url.startsWith("http://" + rule.host + path.path)) { + if(this.matchUrl(ingress,this.search_url,rule.host,path.path,path.pathType)){ is_same_path = true break } - } + } } } From 1e8f2d32652b2d487d082c1402b9740c42e77ffa Mon Sep 17 00:00:00 2001 From: awol2005ex Date: Fri, 7 Feb 2025 15:49:59 +0800 Subject: [PATCH 3/3] =?UTF-8?q?ingress=20search=20=E5=8C=B9=E9=85=8Durl=20?= =?UTF-8?q?bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/business/network/ingresses/ingress-search.vue | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/web/dashboard/src/business/network/ingresses/ingress-search.vue b/web/dashboard/src/business/network/ingresses/ingress-search.vue index d1a1ff4d..f65306d8 100644 --- a/web/dashboard/src/business/network/ingresses/ingress-search.vue +++ b/web/dashboard/src/business/network/ingresses/ingress-search.vue @@ -163,6 +163,14 @@ export default { return str + "/"; } }, + toEndExp(s) { + const str = s || ""; + if (str.endsWith("/")) { + return str; + } else { + return str + "(/|$)"; + } + }, matchUrl(ingress, url,host ,path,pathType) { let urlForMatch =""; @@ -179,7 +187,7 @@ export default { if(this.toEnd(url).startsWith(this.toEnd(urlForMatch))){ return true } else { - if(this.toEnd(url).match(this.toEnd(urlForMatch))){ + if(this.toEnd(url).match(this.toEndExp(urlForMatch))){ return true } else { return false