Skip to content

Commit

Permalink
优化json解析。
Browse files Browse the repository at this point in the history
  • Loading branch information
wangliang181230 committed Jan 16, 2025
1 parent db7b0f9 commit 3ae6282
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/core/src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,10 @@ function _getConfig () {
return {}
}

if (!fs.existsSync(configFilePath)) {
return {}
}

return jsonApi.parse(fs.readFileSync(configFilePath))
}

Expand Down
3 changes: 3 additions & 0 deletions packages/mitmproxy/src/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ if (JSON5.default) {

module.exports = {
parse (str) {
if (str == null || str.length < 2) {
return {}
}
return JSON5.parse(str)
},
stringify (obj) {
Expand Down

0 comments on commit 3ae6282

Please sign in to comment.