Skip to content

Commit b4c1dc9

Browse files
committed
fix: add str.replace checks, closes #1531
1 parent a2f5ee5 commit b4c1dc9

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

packages/app-frontend/src/mixins/data-field-edit.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -178,19 +178,21 @@ export default {
178178
},
179179

180180
transformSpecialTokens (str, display) {
181-
Object.keys(SPECIAL_TOKENS).forEach(key => {
182-
const value = JSON.stringify(SPECIAL_TOKENS[key])
183-
let search
184-
let replace
185-
if (display) {
186-
search = value
187-
replace = key
188-
} else {
189-
search = key
190-
replace = value
191-
}
192-
str = str.replace(new RegExp(search, 'g'), replace)
193-
})
181+
if (str) {
182+
Object.keys(SPECIAL_TOKENS).forEach(key => {
183+
const value = JSON.stringify(SPECIAL_TOKENS[key])
184+
let search
185+
let replace
186+
if (display) {
187+
search = value
188+
replace = key
189+
} else {
190+
search = key
191+
replace = value
192+
}
193+
str = str.replace(new RegExp(search, 'g'), replace)
194+
})
195+
}
194196
return str
195197
},
196198

packages/shared-utils/src/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const classify = cached((str) => {
2626

2727
const camelizeRE = /-(\w)/g
2828
export const camelize = cached((str) => {
29-
return str.replace(camelizeRE, toUpper)
29+
return str && str.replace(camelizeRE, toUpper)
3030
})
3131

3232
const kebabizeRE = /([a-z0-9])([A-Z])/g

0 commit comments

Comments
 (0)