Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Context-insensitive parsing of sourceMappingURL #467

Open
lachrist opened this issue Apr 24, 2023 · 0 comments
Open

Context-insensitive parsing of sourceMappingURL #467

lachrist opened this issue Apr 24, 2023 · 0 comments

Comments

@lachrist
Copy link

  • Version: v18.13.0
  • Platform: Darwin softs-MBP 19.6.0 Darwin Kernel Version 19.6.0: Tue Jun 21 21:18:39 PDT 2022; root:xnu-6153.141.66~1/RELEASE_X86_64 x86_64
  • c8: 7.13.0

First of all, thanks for your work!

The current regexp-based parsing of sourcemap urls does not consider the context where sourceMappingURL= appears:

const sourceMapLineRE = /\/[*/]#\s+sourceMappingURL=(?<sourceMappingURL>[^\s]+)/

This causes files where sourceMappingURL= appears in string literal to not be covered. It would also happens if sourceMappingURL= appears in non-tail comments.

// append-sourcemap-url.mjs

const appendSourcemapUrl = (content, sourcemap) =>
  `${content}\n//# sourceMappingURL=data:text/json,${encodeURIComponent(sourcemap)}`;

appendSourcemapUrl("123;", '{"version":3}');
npx c8 -- node append-sourcemap-url.mjs
----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |                   
----------|---------|----------|---------|---------|-------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant