mirror of
https://github.com/danog/inline-critical.git
synced 2024-11-30 04:29:07 +01:00
fix: consider ignore passed as string
This commit is contained in:
parent
0274c1ec32
commit
184b7b0c70
2
index.js
2
index.js
@ -109,7 +109,7 @@ module.exports = function (html, styles, options) {
|
||||
if (o.ignore) {
|
||||
links = _.filter(links, link => {
|
||||
const href = $(link).attr('href');
|
||||
return _.findIndex(options.ignore, arg => {
|
||||
return _.findIndex(o.ignore, arg => {
|
||||
return (_.isRegExp(arg) && arg.test(href)) || arg === href;
|
||||
}) === -1;
|
||||
});
|
||||
|
@ -168,7 +168,7 @@ describe('Module: inline-critical', function () {
|
||||
done();
|
||||
});
|
||||
|
||||
it('should respect ignore option with string', function (done) {
|
||||
it('should respect ignore option with string array', function (done) {
|
||||
function strip2(string) {
|
||||
return string.replace(/\s+/gm, '');
|
||||
}
|
||||
@ -181,7 +181,22 @@ describe('Module: inline-critical', function () {
|
||||
expect(strip2(out.toString('utf-8'))).to.be.equal(strip2(expected));
|
||||
done();
|
||||
});
|
||||
it('should respect ignore option with RegExp', function (done) {
|
||||
|
||||
it('should respect single ignore option with string', function (done) {
|
||||
function strip2(string) {
|
||||
return string.replace(/\s+/gm, '');
|
||||
}
|
||||
|
||||
var html = read('test/fixtures/external.html');
|
||||
var expected = read('test/expected/external-ignore-expected.html');
|
||||
var css = read('test/fixtures/critical.css');
|
||||
var out = inlineCritical(html, css, {minify: false, ignore: 'bower_components/bootstrap/dist/css/bootstrap.css'});
|
||||
|
||||
expect(strip2(out.toString('utf-8'))).to.be.equal(strip2(expected));
|
||||
done();
|
||||
});
|
||||
|
||||
it('should respect ignore option with RegExp array', function (done) {
|
||||
function strip2(string) {
|
||||
return string.replace(/\s+/gm, '');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user