Skip to content

Commit 276be2b

Browse files
committed
don't do any replacement if theres an empty string
1 parent e9fa45e commit 276be2b

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

lib/ExpensiMark.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,10 @@ export default class ExpensiMark {
951951
* If not provided, all available rules will be applied. If provided, the rules in the array will be skipped.
952952
*/
953953
replace(text: string, {filterRules = [], shouldEscapeText = true, shouldKeepRawInput = false, disabledRules = [], extras = EXTRAS_DEFAULT}: ReplaceOptions = {}): string {
954+
if (!text) {
955+
return '';
956+
}
957+
954958
// This ensures that any html the user puts into the comment field shows as raw html
955959
let replacedText = shouldEscapeText ? Utils.escapeText(text) : text;
956960
const rules = this.getHtmlRuleset(filterRules, disabledRules, shouldKeepRawInput);
@@ -987,6 +991,7 @@ export default class ExpensiMark {
987991
/**
988992
* Checks matched URLs for validity and replace valid links with html elements
989993
*/
994+
// TODO
990995
modifyTextForUrlLinks(regex: RegExp, textToCheck: string, replacement: ReplacementFn): string {
991996
let match = regex.exec(textToCheck);
992997
let replacedText = '';

0 commit comments

Comments
 (0)