Skip to content

Commit

Permalink
Add support for utf8 name in input source map encoding
Browse files Browse the repository at this point in the history
Backported from postcss/postcss@215ed88

Fixes #13
  • Loading branch information
xzyfer committed Dec 3, 2018
1 parent 07c1917 commit cef5140
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/previous-map.js
Expand Up @@ -36,15 +36,23 @@ 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) );

} 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);
Expand Down

0 comments on commit cef5140

Please sign in to comment.