instascan icon indicating copy to clipboard operation
instascan copied to clipboard

Fix sourceRegex

Open jc-lab opened this issue 4 years ago • 0 comments

Fix error caused by the wrong sourceRegex in webpack environment.

zxing.js?2fed:1 Uncaught TypeError: Cannot read property 'slice' of null
    at parseJSFunc (zxing.js?2fed:1)
    at eval (zxing.js?2fed:1)
    at module.exports (zxing.js?2fed:1)
    at eval (scanner.js?63ee:2)
    at Object../vendor/instascan/src/scanner.js (app.js:9060)
    at __webpack_require__ (app.js:727)
    at fn (app.js:101)
    at eval (index.js?aa2c:5)
    at Object../vendor/instascan/index.js (app.js:9038)
    at __webpack_require__ (app.js:727)

Fix

var sourceRegex = /^function\s*\(([^)]*)\)\s*{\s*([^*]*?)[\s;]*(?:return\s*(.*?)[;\s]*)?}$/;

Into

var sourceRegex = /^function\s*\S*\(([^)]*)\)\s*{\s*([^*]*?)[\s;]*(?:return\s*(.*?)[;\s]*)?}$/;

jc-lab avatar Sep 24 '19 00:09 jc-lab