Skip to content

Commit

Permalink
Protect internal fields
Browse files Browse the repository at this point in the history
Protect internal fields to prevent regular replacements from being empty
  • Loading branch information
zoushucai committed Nov 28, 2023
1 parent c2f5a06 commit e4c1738
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions introduce.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@

- 支持对同一个字段进行多次操作

- 如果内部字段被置为空, 则不进行操作(保护一下)

```json
[
{
Expand Down
5 changes: 4 additions & 1 deletion src/modules/replacehandle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,10 @@ class replaceHandle {
// const fieldValue = FeildExport.getPublicationTitleForItemType(item);
ztoolkit.ExtraField.setExtraField(item, "itemBoxRowabbr", replaceContent);
} else {
item.setField(m_entry.replaceField, replaceContent);
// 保护一下, 防止替换后的内容为空
if (replaceContent && replaceContent !== "undefined"){
item.setField(m_entry.replaceField, replaceContent);
}
}

const removeTags = Array.from(removeTagsSet).filter((tag) => itemTags.some((t: any) => t.tag === tag));
Expand Down

0 comments on commit e4c1738

Please sign in to comment.