diff --git a/src/reloader.js b/src/reloader.js index 461a1cf..5a52c02 100644 --- a/src/reloader.js +++ b/src/reloader.js @@ -29,7 +29,7 @@ const splitUrl = function (url) { const pathFromUrl = function (url) { if (!url) { - return ""; + return ''; } let path; ({ url } = splitUrl(url)); @@ -292,7 +292,11 @@ class Reloader { } this.console.log(`LiveReload found ${links.length} LINKed stylesheets, ${imported.length} @imported stylesheets`); - const match = pickBestMatch(path, links.concat(imported), l => pathFromUrl(this.linkHref(l))); + const match = pickBestMatch( + path, + links.concat(imported), + link => pathFromUrl(this.linkHref(link)) + ); if (match) { if (match.object.rule) { diff --git a/test/reloader_test.js b/test/reloader_test.js index 4c21e05..a68c57b 100644 --- a/test/reloader_test.js +++ b/test/reloader_test.js @@ -35,6 +35,20 @@ describe('Reloader', () => { assert(reloader); }); + describe('linkHref()', () => { + it('should not throw when no value is available', () => { + const reloader = new Reloader( + { }, + console, + Timer + ); + + assert.doesNotThrow(() => { + reloader.linkHref({}); + }); + }); + }); + describe('reload()', () => { it('should reload the page', (done) => { const reloader = new Reloader( @@ -152,6 +166,7 @@ describe('Reloader', () => { }, 100); }); }); + describe('reload() with plugin order', () => { it('should reload with same plugin order', (done) => { const reloader = new Reloader(