Skip to content

Commit

Permalink
feat: add new mime types
Browse files Browse the repository at this point in the history
  • Loading branch information
JadsonLucena committed Mar 23, 2023
1 parent e6a423b commit 3ee853a
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/MimeTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,33 @@ class MimeTypes {

}

append(mimeType, extension) {

extension = [].concat(extension);

if (typeof mimeType != 'string' || !mimeType.trim() || !/^.+\/.+$/i.test(mimeType)) {

throw new TypeError('Unsupported mimeType');

} else if (!extension.every(extension => typeof extension == 'string' && extension.trim() && /^[a-z0-9-_+.~%]+$/i.test(extension))) {

throw new TypeError('Unsupported extension');

}


let content = {};
content[mimeType] = extension;


if (this.#updateList(content)) {

fs.writeFileSync('mimetypes.json', JSON.stringify(this.#mimeTypes));

}

}

}


Expand Down

0 comments on commit 3ee853a

Please sign in to comment.