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

Sourcemap tracker fails when input sourcemap is data URI (inline) #599

Closed
cspotcode opened this issue Jun 12, 2015 · 1 comment
Closed

Comments

@cspotcode
Copy link
Contributor

In "input-source-map-tracker.js", it automatically locates the /*#sourceMappingURL= in the input .css file (very cool!) but does not account for the possibility that the URL is a data URI:

/* for example, an inline sourcemap generated by Stylus */
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImF..... */

https:/jakubpawlowicz/clean-css/blob/master/lib/utils/input-source-map-tracker.js#L71-L73

It attempts to read this file off disc:
/path/to/source/data:application;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImF.....
which throws an ENAMETOOLONG error.

I think a fix is fairly simple. Add a dependency on a data URI parsing library. Check the sourceMapFile against a data URI regexp, perhaps /^data:/. If it matches the regexp, parse it as a data URI. Otherwise keep the current behavior: reading a file off disc.

@cspotcode
Copy link
Contributor Author

I wrote a patch that implements the fix:
#600

I didn't write any tests, though. If you want to merge this, I can look into making some tests.

jakubpawlowicz pushed a commit that referenced this issue Jun 16, 2015
Enables ingestion of inline, data-uri source maps.
jakubpawlowicz pushed a commit that referenced this issue Jun 22, 2015
Enables ingestion of inline, data-uri source maps.
jakubpawlowicz added a commit that referenced this issue Jun 23, 2015
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