From 5e543a2387ec577122b95061d30a221f7e35a396 Mon Sep 17 00:00:00 2001 From: Kevin Ghadyani Date: Thu, 11 Jan 2018 13:37:39 -0600 Subject: [PATCH 1/2] Fixed interpolate=require prepending `./` to url This fixes bug #150 where the URL passed to `require()` would have `./` prepended when it shouldn't. --- index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/index.js b/index.js index 5b8b3618..bb1c887b 100644 --- a/index.js +++ b/index.js @@ -147,6 +147,15 @@ module.exports = function(content) { return exportsString + content.replace(/xxxHTMLLINKxxx[0-9\.]+xxx/g, function(match) { if(!data[match]) return match; + + var urlToRequest; + + if (config.interpolate === 'require') { + urlToRequest = data[match]; + } else { + urlToRequest = loaderUtils.urlToRequest(data[match], root); + } + return '" + require(' + JSON.stringify(loaderUtils.urlToRequest(data[match], root)) + ') + "'; }) + ";"; From 8a420a9a0235ffaec2e7eee676df24fb5885ee4a Mon Sep 17 00:00:00 2001 From: Kevin Ghadyani Date: Mon, 15 Jan 2018 09:34:31 -0600 Subject: [PATCH 2/2] Corrected issue where `urlToRequest` wasn't referenced after it was created --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index bb1c887b..a7445b6c 100644 --- a/index.js +++ b/index.js @@ -156,7 +156,7 @@ module.exports = function(content) { urlToRequest = loaderUtils.urlToRequest(data[match], root); } - return '" + require(' + JSON.stringify(loaderUtils.urlToRequest(data[match], root)) + ') + "'; + return '" + require(' + JSON.stringify(urlToRequest) + ') + "'; }) + ";"; }