diff --git a/.gitignore b/.gitignore
index d5fd449..d4e3490 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@
node_modules/
npm-debug.log
test/fixtures/css/cartoon.18d89c7f.css
+test/fixtures/css/main.158f2990.css
diff --git a/index.js b/index.js
index de72c3b..a4396d4 100644
--- a/index.js
+++ b/index.js
@@ -74,8 +74,8 @@ module.exports = function(html, styles, options) {
}
hrefs = hrefs.map(function(href) {
var file = path.resolve(o.basePath, href);
- if (!fs.existsSync(file)) {
- return;
+ if (!fs.existsSync(file) ) {
+ return href;
}
var diff = normalizeNewline(cave(file, { css: styles }));
fs.writeFileSync(reaver.rev(file, diff), diff);
diff --git a/test/expected/external-expected.html b/test/expected/external-expected.html
new file mode 100644
index 0000000..0590808
--- /dev/null
+++ b/test/expected/external-expected.html
@@ -0,0 +1,408 @@
+
+
+
+
+ critical css test
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
'Allo, 'Allo!
+
+
Always a pleasure scaffolding your apps.
+
+
Splendid!
+
+
+
+
+
HTML5 Boilerplate
+
+
HTML5 Boilerplate is a professional front-end template for building fast, robust, and adaptable web apps or
+ sites.
+
+
Bootstrap
+
+
Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
+
+
+
+
+
+
+
diff --git a/test/expected/external-extract-expected.html b/test/expected/external-extract-expected.html
new file mode 100644
index 0000000..239eca7
--- /dev/null
+++ b/test/expected/external-extract-expected.html
@@ -0,0 +1,352 @@
+
+
+
+
+ critical css test
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
'Allo, 'Allo!
+
Always a pleasure scaffolding your apps.
+
Splendid!
+
+
+
+
+
HTML5 Boilerplate
+
HTML5 Boilerplate is a professional front-end template for building fast, robust, and adaptable web apps or sites.
+
+
Bootstrap
+
Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
+
+
+
+
+
+
+
diff --git a/test/fixtures/external.html b/test/fixtures/external.html
new file mode 100644
index 0000000..00cbb91
--- /dev/null
+++ b/test/fixtures/external.html
@@ -0,0 +1,53 @@
+
+
+
+
+ critical css test
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
'Allo, 'Allo!
+
Always a pleasure scaffolding your apps.
+
Splendid!
+
+
+
+
+
HTML5 Boilerplate
+
HTML5 Boilerplate is a professional front-end template for building fast, robust, and adaptable web apps or sites.
+
+
Bootstrap
+
Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
+
+
+
+
+
+
+
diff --git a/test/index.js b/test/index.js
index ea953f6..2a7b24f 100644
--- a/test/index.js
+++ b/test/index.js
@@ -65,4 +65,38 @@ describe('inline-critical', function() {
expect(strip(out.toString('utf-8'))).to.be.equal(strip(html));
done();
});
+
+ it('should not keep external urls', function(done) {
+
+ function strip2(string) {
+ return string.replace(/\s+/gm,'');
+ }
+
+ var html = read('test/fixtures/external.html');
+ var expected = read('test/expected/external-expected.html');
+ var css = read('test/fixtures/critical.css');
+ var out = inlineCritical(html, css);
+
+ write('test/expected/external-expected2.html',out);
+
+ expect(strip2(out.toString('utf-8'))).to.be.equal(strip2(expected));
+ done();
+ });
+
+ it('should not keep external urls on extract', function(done) {
+
+ function strip2(string) {
+ return string.replace(/\s+/gm,'');
+ }
+
+ var html = read('test/fixtures/external.html');
+ var expected = read('test/expected/external-extract-expected.html');
+ var css = read('test/fixtures/critical.css');
+ var out = inlineCritical(html, css, { extract: true, basePath: 'test/fixtures' });
+
+ write('test/expected/external-expected2.html',out);
+
+ expect(strip2(out.toString('utf-8'))).to.be.equal(strip2(expected));
+ done();
+ });
});