Skip to content

Having multiple @import in one file throws a TypeError #73

@mcibique

Description

@mcibique

I'm using postcss-cachebuster@0.1.3 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions