From 0d6fdec4bd44c6146a100524d3aaff88bbde5d48 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Fri, 8 Feb 2019 22:10:20 +0000 Subject: [PATCH] fix(compiler): support `sourceMappingURL` comments that have trailing lines (#28055) Previously the call to `extractSourceMap()` would only work if the `//#sourceMappingURL ...` was the last line of the file. This doesn't work if the code is JIT evaluated as the comment is actually the last line in the body of a function, wrapped by curly-braces. PR Close #28055 --- packages/compiler/testing/src/output/source_map_util.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/compiler/testing/src/output/source_map_util.ts b/packages/compiler/testing/src/output/source_map_util.ts index 6280d0393a..941a735c29 100644 --- a/packages/compiler/testing/src/output/source_map_util.ts +++ b/packages/compiler/testing/src/output/source_map_util.ts @@ -29,7 +29,7 @@ export function originalPositionFor( export function extractSourceMap(source: string): SourceMap|null { let idx = source.lastIndexOf('\n//#'); if (idx == -1) return null; - const smComment = source.slice(idx).trim(); + const smComment = source.slice(idx).split('\n', 2)[1].trim(); const smB64 = smComment.split('sourceMappingURL=data:application/json;base64,')[1]; return smB64 ? JSON.parse(decodeB64String(smB64)) : null; }