mirror of
https://github.com/komodorio/helm-dashboard.git
synced 2026-03-26 06:18:04 +00:00
Fix JS error on version parsing
This commit is contained in:
@@ -44,9 +44,16 @@ function buildChartCard(elm) {
|
|||||||
<div class="col-1 rel-date text-nowrap"><span>today</span><div>Updated</div></div>
|
<div class="col-1 rel-date text-nowrap"><span>today</span><div>Updated</div></div>
|
||||||
</div>`)
|
</div>`)
|
||||||
|
|
||||||
|
let chartName = elm.chart
|
||||||
// semver2 regex , add optional v prefix
|
// semver2 regex , add optional v prefix
|
||||||
const chartNameRegex = 'v?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?'
|
const chartNameRegex = 'v?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?'
|
||||||
const chartName = elm.chart.substring(0, elm.chart.match(chartNameRegex).index - 1)
|
const match = elm.chart.match(chartNameRegex);
|
||||||
|
if (match) {
|
||||||
|
chartName = elm.chart.substring(0, match.index - 1)
|
||||||
|
} else {
|
||||||
|
// fall back to simple substr
|
||||||
|
chartName = elm.chart.substring(0, elm.chart.lastIndexOf("-"))
|
||||||
|
}
|
||||||
$.getJSON("/api/helm/repo/search?name=" + chartName).fail(function (xhr) {
|
$.getJSON("/api/helm/repo/search?name=" + chartName).fail(function (xhr) {
|
||||||
// we're ok if we can't show icon and description
|
// we're ok if we can't show icon and description
|
||||||
console.log("Failed to get repo name for charts", xhr)
|
console.log("Failed to get repo name for charts", xhr)
|
||||||
|
|||||||
Reference in New Issue
Block a user