Skip to content

Commit

Permalink
fix: 将错误信息中的双引号替换成单引号
Browse files Browse the repository at this point in the history
  • Loading branch information
strick committed Jul 11, 2023
1 parent 0e3e776 commit 01bb02f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
4 changes: 3 additions & 1 deletion dist/shin.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,12 +531,14 @@ var ErrorMonitor = /** @class */ (function () {
* https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Error
*/
ErrorMonitor.prototype.formatRuntimerError = function (message, filename, lineno, colno) {
// 需要将 message 中的双引号替换成单引号,便于数据库搜索,不然很有可能因为反斜杠影响查询结果
var m = message.replace(/"/g, '\'');
return {
type: CONSTANT.ERROR_RUNTIME,
lineno: lineno,
colno: colno,
desc: {
prompt: (message + ' at ' + filename + ':' + lineno + ':' + colno),
prompt: (m + ' at ' + filename + ':' + lineno + ':' + colno),
url: location.href
},
};
Expand Down
4 changes: 3 additions & 1 deletion dist/shin.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,12 +533,14 @@ var ErrorMonitor = /** @class */ (function () {
* https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Error
*/
ErrorMonitor.prototype.formatRuntimerError = function (message, filename, lineno, colno) {
// 需要将 message 中的双引号替换成单引号,便于数据库搜索,不然很有可能因为反斜杠影响查询结果
var m = message.replace(/"/g, '\'');
return {
type: CONSTANT.ERROR_RUNTIME,
lineno: lineno,
colno: colno,
desc: {
prompt: (message + ' at ' + filename + ':' + lineno + ':' + colno),
prompt: (m + ' at ' + filename + ':' + lineno + ':' + colno),
url: location.href
},
};
Expand Down
2 changes: 1 addition & 1 deletion dist/shin.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion dist/shin.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -537,12 +537,14 @@
* https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Error
*/
ErrorMonitor.prototype.formatRuntimerError = function (message, filename, lineno, colno) {
// 需要将 message 中的双引号替换成单引号,便于数据库搜索,不然很有可能因为反斜杠影响查询结果
var m = message.replace(/"/g, '\'');
return {
type: CONSTANT.ERROR_RUNTIME,
lineno: lineno,
colno: colno,
desc: {
prompt: (message + ' at ' + filename + ':' + lineno + ':' + colno),
prompt: (m + ' at ' + filename + ':' + lineno + ':' + colno),
url: location.href
},
};
Expand Down
6 changes: 4 additions & 2 deletions src/lib/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: strick
* @LastEditors: strick
* @Date: 2023-01-12 14:21:36
* @LastEditTime: 2023-07-03 18:00:53
* @LastEditTime: 2023-07-11 14:59:25
* @Description: 监控各类错误
* @FilePath: /web/shin-monitor/src/lib/error.ts
*/
Expand Down Expand Up @@ -303,12 +303,14 @@ class ErrorMonitor {
* https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Error
*/
private formatRuntimerError(message: string, filename: string, lineno: number, colno: number): TypeErrorData {
// 需要将 message 中的双引号替换成单引号,便于数据库搜索,不然很有可能因为反斜杠影响查询结果
const m = message.replace(/"/g, '\'');
return {
type: CONSTANT.ERROR_RUNTIME,
lineno,
colno,
desc: {
prompt: (message + ' at ' + filename + ':' + lineno + ':' + colno),
prompt: (m + ' at ' + filename + ':' + lineno + ':' + colno),
url: location.href
},
// stack: error && (error.stack ? error.stack : "no stack") // IE <9, has no error stack
Expand Down

0 comments on commit 01bb02f

Please sign in to comment.