From d74123207366ab56fb8813286c331e437afbe507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86ndrew=20Rininsland?= Date: Mon, 20 Oct 2014 17:07:03 +0100 Subject: [PATCH] Adding support for a single srcset item. See #428. --- lib/fileprocessor.js | 4 ++++ test/test-fileprocessor.js | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/fileprocessor.js b/lib/fileprocessor.js index 67a036d..a4fd3f1 100644 --- a/lib/fileprocessor.js +++ b/lib/fileprocessor.js @@ -70,6 +70,10 @@ var _defaultPatterns = { [ /]*[^\>\S]+src=['"]([^"']+)["']/gm, 'Update the HTML with the new image filenames for src links' + ], + [ + /<(?:img|source)[^\>]*[^\>\S]+srcset=['"]([^"'\s]+)(?:\s\d[mx])["']/gm, + 'Update the HTML with the new image filenames for srcset links' ] ], css: [ diff --git a/test/test-fileprocessor.js b/test/test-fileprocessor.js index f421c74..7477d14 100644 --- a/test/test-fileprocessor.js +++ b/test/test-fileprocessor.js @@ -231,6 +231,7 @@ describe('FileProcessor', function () { 'app/bar.css': 'bar.5678.css', 'app/baz.css': '/baz.8910.css', 'app/image.png': 'image.1234.png', + 'app/image@2x.png': 'image@2x.1234.png', 'app/video.webm': 'video.1234.webm', 'tmp/bar.css': 'bar.1234.css', 'app/foo.js': 'foo.1234.js', @@ -427,6 +428,15 @@ describe('FileProcessor', function () { assert.equal(replaced, ''); }); + it('should replace img reference in srcset', function () { + var content = ''; + var replaced = fp.replaceWithRevved(content, ['app']); + assert.equal(replaced, ''); + + content = ''; + replaced = fp.replaceWithRevved(content, ['app']); + assert.equal(replaced, ''); + }); }); describe('css type', function () {