mirror of
https://github.com/komodorio/helm-dashboard.git
synced 2026-03-24 11:48:04 +00:00
Handle errors in regex match
This commit is contained in:
@@ -45,9 +45,15 @@ function buildChartCard(elm) {
|
|||||||
</div>`)
|
</div>`)
|
||||||
|
|
||||||
let chartName = elm.chart
|
let chartName = elm.chart
|
||||||
|
let match = null
|
||||||
// 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 match = elm.chart.match(chartNameRegex);
|
if (!new RegExp(chartNameRegex).test(chartName)) {
|
||||||
|
alert('Chart name does not match chart name regex.')
|
||||||
|
} else {
|
||||||
|
match = chartName.match(chartNameRegex);
|
||||||
|
}
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
chartName = elm.chart.substring(0, match.index - 1)
|
chartName = elm.chart.substring(0, match.index - 1)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user