@@ -20,15 +20,15 @@ export const checkJSONPathStarts$ = (firstChar, formVal): string | null => {
2020export const sanitizeForm = ( form : Subscription ) : Subscription => {
2121 // add $. if not at start of input for json paths
2222 if ( form . jsonMeasurementKey ) {
23- const startChar = form . jsonMeasurementKey . path . charAt ( 0 )
23+ const startChar = form . jsonMeasurementKey ? .path . charAt ( 0 ) ?? ''
2424 const newVal = checkJSONPathStarts$ ( startChar , form . jsonMeasurementKey . path )
2525 if ( newVal ) {
2626 form . jsonMeasurementKey . path = newVal
2727 }
2828 }
2929 if ( form . jsonFieldKeys ) {
3030 form . jsonFieldKeys . map ( f => {
31- const startChar = f . path . charAt ( 0 )
31+ const startChar = f . path ? .charAt ( 0 ) ?? ''
3232 const newVal = checkJSONPathStarts$ ( startChar , f . path )
3333 if ( newVal ) {
3434 f . path = newVal
@@ -37,14 +37,14 @@ export const sanitizeForm = (form: Subscription): Subscription => {
3737 }
3838 if ( form . jsonTagKeys ) {
3939 form . jsonTagKeys . map ( t => {
40- const startChar = t . path . charAt ( 0 )
40+ const startChar = t . path ? .charAt ( 0 ) ?? ''
4141 const newVal = checkJSONPathStarts$ ( startChar , t . path )
4242 if ( newVal ) {
4343 t . path = newVal
4444 }
4545 } )
4646 }
47- if ( form . jsonTimestamp . path ) {
47+ if ( form . jsonTimestamp ? .path ) {
4848 const startChar = form . jsonTimestamp . path . charAt ( 0 )
4949 const newVal = checkJSONPathStarts$ ( startChar , form . jsonTimestamp . path )
5050
@@ -53,26 +53,24 @@ export const sanitizeForm = (form: Subscription): Subscription => {
5353 }
5454 }
5555
56- if ( form . jsonTimestamp . path === '' ) {
56+ if ( form . jsonTimestamp ? .path === '' ) {
5757 delete form . jsonTimestamp
5858 }
5959 if ( form . stringMeasurement ) {
60- form . stringMeasurement . pattern = form . stringMeasurement . pattern . replace (
61- / \\ \\ / g,
62- '\\'
63- )
60+ form . stringMeasurement . pattern =
61+ form . stringMeasurement ?. pattern . replace ( / \\ \\ / g, '\\' ) ?? ''
6462 }
6563 if ( form . stringFields ) {
6664 form . stringFields . map ( f => {
67- f . pattern = f . pattern . replace ( / \\ \\ / g, '\\' )
65+ f . pattern = f . pattern ? .replace ( / \\ \\ / g, '\\' ) ?? ''
6866 } )
6967 }
7068 if ( form . stringTags ) {
7169 form . stringTags . map ( t => {
72- t . pattern = t . pattern . replace ( / \\ \\ / g, '\\' )
70+ t . pattern = t . pattern ? .replace ( / \\ \\ / g, '\\' ) ?? ''
7371 } )
7472 }
75- if ( form . stringTimestamp . pattern === '' ) {
73+ if ( form . stringTimestamp ? .pattern === '' ) {
7674 delete form . stringTimestamp
7775 }
7876 if ( form . brokerPassword === '' || form . brokerUsername === '' ) {
0 commit comments