LaKing / ep_codepad

Turn etherpad-lite into a realtime collaborative online development environment
30 stars 7 forks source link

Note: mime.lookup renamed to mime.getExtension #16

Open pongraczi opened 5 years ago

pongraczi commented 5 years ago

Background

The mime package changed from 1.x to 2.x and mime.lookup renamed to mime.getExtension.
Codepad use it, but expect 1.x and does not prepared for 2.x

Result

Using codepad, etherpad-lite will crash, you will be frustrated.

How to fix it

Now you will be happy, it will work as expected.

ProdigyView commented 3 years ago

@pongraczi would it be easier to have lookup call get extension?

mime.lookup(path) {
    return mime.getExtension(path);
}

Or in etherpad-lite/node_modules/mime/Mime.js

function Mime() {
  this._types = Object.create(null);
  this._extensions = Object.create(null);

  for (let i = 0; i < arguments.length; i++) {
    this.define(arguments[i]);
  }

  this.define = this.define.bind(this);
  this.getType = this.getType.bind(this);
  this.getExtension = this.getExtension.bind(this);
  this.lookup = this.getExtension;
}

Or something to that effect? (I havent gotten this working yet as my updates are not in the build)