1111 * @private
1212 */
1313
14- var createError = require ( 'http-errors' )
15- var getBody = require ( 'raw-body' )
16- var iconv = require ( 'iconv-lite' )
17- var onFinished = require ( 'on-finished' )
18- var zlib = require ( 'node:zlib' )
19- var hasBody = require ( 'type-is' ) . hasBody
20- var { getCharset } = require ( './utils' )
14+ const createError = require ( 'http-errors' )
15+ const getBody = require ( 'raw-body' )
16+ const iconv = require ( 'iconv-lite' )
17+ const onFinished = require ( 'on-finished' )
18+ const zlib = require ( 'node:zlib' )
19+ const hasBody = require ( 'type-is' ) . hasBody
20+ const { getCharset } = require ( './utils' )
2121
2222/**
2323 * Module exports.
@@ -63,7 +63,7 @@ function read (req, res, next, parse, debug, options) {
6363 return
6464 }
6565
66- var encoding = null
66+ let encoding = null
6767 if ( options ?. skipCharset !== true ) {
6868 encoding = getCharset ( req ) || options . defaultCharset
6969
@@ -78,12 +78,12 @@ function read (req, res, next, parse, debug, options) {
7878 }
7979 }
8080
81- var length
82- var opts = options
83- var stream
81+ let length
82+ const opts = options
83+ let stream
8484
8585 // read options
86- var verify = opts . verify
86+ const verify = opts . verify
8787
8888 try {
8989 // get the content stream
@@ -112,7 +112,7 @@ function read (req, res, next, parse, debug, options) {
112112 debug ( 'read body' )
113113 getBody ( stream , opts , function ( error , body ) {
114114 if ( error ) {
115- var _error
115+ let _error
116116
117117 if ( error . type === 'encoding.unsupported' ) {
118118 // echo back charset
@@ -153,7 +153,7 @@ function read (req, res, next, parse, debug, options) {
153153 }
154154
155155 // parse
156- var str = body
156+ let str = body
157157 try {
158158 debug ( 'parse body' )
159159 str = typeof body !== 'string' && encoding !== null
@@ -182,8 +182,8 @@ function read (req, res, next, parse, debug, options) {
182182 * @private
183183 */
184184function contentstream ( req , debug , inflate ) {
185- var encoding = ( req . headers [ 'content-encoding' ] || 'identity' ) . toLowerCase ( )
186- var length = req . headers [ 'content-length' ]
185+ const encoding = ( req . headers [ 'content-encoding' ] || 'identity' ) . toLowerCase ( )
186+ const length = req . headers [ 'content-length' ]
187187
188188 debug ( 'content-encoding "%s"' , encoding )
189189
@@ -199,7 +199,7 @@ function contentstream (req, debug, inflate) {
199199 return req
200200 }
201201
202- var stream = createDecompressionStream ( encoding , debug )
202+ const stream = createDecompressionStream ( encoding , debug )
203203 req . pipe ( stream )
204204 return stream
205205}
0 commit comments