From cef5140251617c6d15cf639a4ffda246b7704344 Mon Sep 17 00:00:00 2001 From: xzyfer Date: Mon, 3 Dec 2018 22:01:14 +1100 Subject: [PATCH] Add support for utf8 name in input source map encoding Backported from https://github.com/postcss/postcss/commit/215ed88db2e6e180f7f07750ddc1540de4ad25d2 Fixes #13 --- src/previous-map.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/previous-map.js b/src/previous-map.js index 24c7a42..ffc1f79 100644 --- a/src/previous-map.js +++ b/src/previous-map.js @@ -36,8 +36,10 @@ export default class PreviousMap { } decodeInline(text) { + let utfd64 = 'data:application/json;charset=utf-8;base64,'; + let utf64 = 'data:application/json;charset=utf8;base64,'; + let b64 = 'data:application/json;base64,'; let uri = 'data:application/json,'; - let base64 = 'data:application/json;base64,'; if ( this.startWith(text, uri) ) { return decodeURIComponent( text.substr(uri.length) ); @@ -45,6 +47,12 @@ export default class PreviousMap { } else if ( this.startWith(text, base64) ) { return Base64.decode( text.substr(base64.length) ); + } else if ( this.startWith(text, utf64) ) { + return Base64.decode( text.substr(utf64.length) ); + + } else if ( this.startWith(text, utfd64) ) { + return Base64.decode( text.substr(utfd64.length) ); + } else { let encoding = text.match(/data:application\/json;([^,]+),/)[1]; throw new Error('Unsupported source map encoding ' + encoding);