@@ -102,6 +102,12 @@ module.exports = CoreObject.extend({
102
102
}
103
103
} ,
104
104
105
+ _mimeCharsetsLookup : function ( mimeType , fallback ) {
106
+ // the node-mime library removed this method in v 2.0. This is the replacement
107
+ // code for what was formerly mime.charsets.lookup
108
+ return ( / ^ t e x t \/ | ^ a p p l i c a t i o n \/ ( j a v a s c r i p t | j s o n ) / ) . test ( mimeType ) ? 'UTF-8' : fallback ;
109
+ } ,
110
+
105
111
_putObject : function ( filePath , options , filePaths ) {
106
112
var plugin = this . plugin ;
107
113
var cwd = options . cwd ;
@@ -119,7 +125,7 @@ module.exports = CoreObject.extend({
119
125
var basePath = path . join ( cwd , filePath ) ;
120
126
var data = fs . readFileSync ( basePath ) ;
121
127
var contentType = mime . getType ( basePath ) ;
122
- var encoding = mime . charsets . lookup ( contentType ) ;
128
+ var encoding = this . _mimeCharsetsLookup ( contentType ) ;
123
129
var key = prefix === '' ? filePath : [ prefix , filePath ] . join ( '/' ) ;
124
130
var isGzipped = gzippedFilePaths . indexOf ( filePath ) !== - 1 ;
125
131
var isBrotliCompressed = brotliCompressedFilePaths . indexOf ( filePath ) !== - 1 ;
@@ -128,14 +134,14 @@ module.exports = CoreObject.extend({
128
134
var basePathUngzipped = path . basename ( basePath , '.gz' ) ;
129
135
if ( filePaths && filePaths . indexOf ( basePathUngzipped ) !== - 1 ) {
130
136
contentType = mime . getType ( basePathUngzipped ) ;
131
- encoding = mime . charsets . lookup ( contentType ) ;
137
+ encoding = this . _mimeCharsetsLookup ( contentType ) ;
132
138
}
133
139
}
134
140
if ( isBrotliCompressed ) {
135
141
var basePathUncompressed = path . basename ( basePath , '.br' ) ;
136
142
if ( filePaths && filePaths . indexOf ( basePathUncompressed ) !== - 1 ) {
137
143
contentType = mime . getType ( basePathUncompressed ) ;
138
- encoding = mime . charsets . lookup ( contentType ) ;
144
+ encoding = this . _mimeCharsetsLookup ( contentType ) ;
139
145
}
140
146
}
141
147
0 commit comments