From 4496948aaffd9c470f3d80f2edf9a4f2eeabdb3c Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Sun, 20 Jun 2021 13:49:23 -0700 Subject: [PATCH] Add a getMIMEType() method to Unarchiver --- archive/archive-internal.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/archive/archive-internal.js b/archive/archive-internal.js index b4e25ab..446b5b2 100644 --- a/archive/archive-internal.js +++ b/archive/archive-internal.js @@ -225,13 +225,22 @@ export class UnarchiveExtractEvent extends UnarchiveEvent { this.worker_ = null; } + /** + * This method must be overridden by the subclass to return the script filename. + * @return {string} The MIME type of the archive. + * @protected. + */ + getMIMEType() { + throw 'Subclasses of Unarchiver must overload getMIMEType()'; + } + /** * This method must be overridden by the subclass to return the script filename. * @return {string} The script filename. * @protected. */ getScriptFileName() { - throw 'Subclasses of AbstractUnarchiver must overload getScriptFileName()'; + throw 'Subclasses of Unarchiver must overload getScriptFileName()'; } /** @@ -376,6 +385,7 @@ export class UnzipperInternal extends Unarchiver { super(arrayBuffer, createWorkerFn, options); } + getMIMEType() { return 'application/zip'; } getScriptFileName() { return 'archive/unzip.js'; } } @@ -384,6 +394,7 @@ export class UnrarrerInternal extends Unarchiver { super(arrayBuffer, createWorkerFn, options); } + getMIMEType() { return 'application/x-rar-compressed'; } getScriptFileName() { return 'archive/unrar.js'; } } @@ -392,6 +403,7 @@ export class UntarrerInternal extends Unarchiver { super(arrayBuffer, createWorkerFn, options); } + getMIMEType() { return 'application/x-tar'; } getScriptFileName() { return 'archive/untar.js'; }; }