postcss-cachebuster icon indicating copy to clipboard operation
postcss-cachebuster copied to clipboard

Having multiple @import in one file throws a TypeError

Open mcibique opened this issue 8 years ago • 2 comments
trafficstars

I'm using [email protected] and I have css file with two imports:

@import "file1.css";
@import "file2.css";

First import is processed properly, but the second one throws an error:

TypeError: Cannot read property '1' of null
    at walkThroughtImports (C:\projects\my-project\node_modules\postcss-cachebuster\index.js:84:26)

It is caused because walkThroughtImports() uses regexp with 'g' flag but do not reset the lastIndex back to 0 after first usage. Adding pattern.lastIndex = 0; before calling pattern.exec(atrule.params) solves the problem.

mcibique avatar Jan 05 '17 15:01 mcibique

Can you create a pull request, please? I will be appreciate ^__^

glebmachine avatar Jan 05 '17 18:01 glebmachine

Sure. #75

mcibique avatar Jan 08 '17 18:01 mcibique