Skip to content

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

@cspotcode

Description

@cspotcode

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://github.com/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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions