On Thu, 24 Mar 2022 15:09:24 +0530 Nilesh Patra <nil...@debian.org> wrote:
> Package: node-send
> Version: 0.17.2-2
> Severity: important
> X-Debbugs-Cc: mer...@debian.org
> 
> Hi Yadd,
> 
> node-send is patched[1] to use node-mime-types instead of node-mime.
> However, this change is breaking node-shiny-server[2] build (not yet uploaded)
> with:
> 
> | TypeError: send.mime.define is not a function
> |    at Object.<anonymous> 
> (/home/nilesh/packages/shinyserv/shiny-server/lib/router/directory-router.js:27:11)
> |    at Module._compile (internal/modules/cjs/loader.js:999:30)
> |    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
> |    at Module.load (internal/modules/cjs/loader.js:863:32)
> 
> mime-types used to have a "define" function which has been removed in 
> version2 of the same.
> It is still not entirely clear to me as to why the patching was needed.
> If possible, can you revert it to use proper node-mime?
> 
> If you happen to drop that patch, some tests fail due to new node-mime API; 
> these can be
> fixed with a simple patch attached with this bug report.

I forgot to attach earlier, should be attached with this mail.

Regards,
Nilesh
--- a/index.js
+++ b/index.js
@@ -835,14 +835,14 @@
 
   if (res.getHeader('Content-Type')) return
 
-  var type = mime.lookup(path)
+  var type = mime.getType(path)
 
   if (!type) {
     debug('no content-type')
     return
   }
 
-  var charset = mime.charsets.lookup(type)
+  var charset = mime.getType(type)
 
   debug('content-type %s', type)
   res.setHeader('Content-Type', type + (charset ? '; charset=' + charset : ''))
--- a/test/send.js
+++ b/test/send.js
@@ -147,12 +147,12 @@
   it('should set Content-Type via mime map', function (done) {
     request(app)
       .get('/name.txt')
-      .expect('Content-Type', 'text/plain; charset=UTF-8')
+      .expect('Content-Type', 'text/plain')
       .expect(200, function (err) {
         if (err) return done(err)
         request(app)
           .get('/tobi.html')
-          .expect('Content-Type', 'text/html; charset=UTF-8')
+          .expect('Content-Type', 'text/html')
           .expect(200, done)
       })
   })

Attachment: signature.asc
Description: PGP signature

Reply via email to