From d3677784dcb2c8fca1d389c84cb14de5242bfc87 Mon Sep 17 00:00:00 2001 From: Jean Ponchon Date: Mon, 25 May 2015 18:01:36 +0200 Subject: [PATCH] Fix inline source-map support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Inline source map prefix should contain an charset: `data:application/json;charset:utf-8;base64,` This is the case with the last releases of browserify for instance. This fix make inline source map detection more flexible to support this *kind* of data url (not only with charset) and use a regexp instead of a static string: `/^data:application\/json[^,]+base64,/` (I didn’t push the generated `browser-source-map-support.js` with this PR, do you want me to ?) --- source-map-support.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/source-map-support.js b/source-map-support.js index 78f7942..a3df0de 100644 --- a/source-map-support.js +++ b/source-map-support.js @@ -92,10 +92,9 @@ function retrieveSourceMap(source) { // Read the contents of the source map var sourceMapData; - var dataUrlPrefix = "data:application/json;base64,"; - if (sourceMappingURL.slice(0, dataUrlPrefix.length).toLowerCase() == dataUrlPrefix) { + if(/^data:application\/json[^,]+base64,/.test(sourceMappingURL)) { // Support source map URL as a data url - sourceMapData = new Buffer(sourceMappingURL.slice(dataUrlPrefix.length), "base64").toString(); + sourceMapData = new Buffer(sourceMappingURL.slice(sourceMappingURL.indexOf(',')+1), "base64").toString(); sourceMappingURL = null; } else { // Support source map URLs relative to the source URL