unminify: Fix source map extraction for hash-named files.

Apparently, our old unminify logic relied on the fact that the
filenames displayed in tracebacks were of the form "app.js" (and the
`app.js` copy of the source map in the appropriate
`/home/zulip/deployments/`).  The correct behavior is to just look up
the source map for the appropriate hash-named
`app.a40806b10565c1dee5bf.js` type file.

We fix this with a few small tweaks to the regular expressions.  I
wish this file had reasonable unit tests.
This commit is contained in:
Tim Abbott
2018-07-30 16:46:48 -07:00
parent 7ea5987e5d
commit 6317064210

View File

@@ -30,10 +30,10 @@ class SourceMap:
out = '' # type: str
for ln in stacktrace.splitlines():
out += ln + '\n'
match = re.search(r'/static/(?:webpack-bundles|min)/(.+)(\.[\.0-9a-f]+)\.js:(\d+):(\d+)', ln)
match = re.search(r'/static/(?:webpack-bundles|min)/(.+)(\.[\.0-9a-f]+\.js):(\d+):(\d+)', ln)
if match:
# Get the appropriate source map for the minified file.
minified_src = match.groups()[0] + '.js'
minified_src = match.groups()[0] + match.groups()[1]
index = self._index_for(minified_src)
gen_line, gen_col = list(map(int, match.groups()[2:4]))