Skip to content

Commit

Permalink
fix: on assetFormat undefined (microsoft#413)
Browse files Browse the repository at this point in the history
* fix: on assetFormat undefined

* fix for multiple toasts

* refactor

* fix for tiff/tif files

* style: fix empty line
  • Loading branch information
alex-krasn authored Jul 15, 2020
1 parent d8fa614 commit 89be3ac
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/services/assetService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ const imageMimes: IMime[] = [
pattern: [0xff, 0xd8, 0xff],
},
{
types: ["tif", "tiff"],
pattern: [0x49, 0x49, 0x42, 0x00],
types: ["tif"],
pattern: [0x49, 0x49, 0x2a, 0x00],
},
{
types: ["tiff"],
pattern: [0x4d, 0x4d, 0x00, 0x2a],
},
{
types: ["pdf"],
Expand Down Expand Up @@ -101,9 +105,8 @@ export class AssetService {
if (!types.includes(assetFormat)) {
assetFormat = types[0];
const corruptFileName = fileName.split("%2F").pop().replace(/%20/g, " ");
setTimeout(() => {
toast.info(`${strings.editorPage.assetWarning.incorrectFileExtension.attention} ${corruptFileName.toLocaleUpperCase()} ${strings.editorPage.assetWarning.incorrectFileExtension.text} ${corruptFileName.toLocaleUpperCase()}`);
}, 3000);

toast.info(`${strings.editorPage.assetWarning.incorrectFileExtension.attention} ${corruptFileName.toLocaleUpperCase()} ${strings.editorPage.assetWarning.incorrectFileExtension.text} ${corruptFileName.toLocaleUpperCase()}`, { delay: 3000 });
}
}

Expand All @@ -125,7 +128,7 @@ export class AssetService {
* @param format - File extension of asset
*/
public static getAssetType(format: string): AssetType {
switch (format.toLowerCase()) {
switch (format?.toLowerCase()) {
case "jpg":
case "jpeg":
case "png":
Expand Down

0 comments on commit 89be3ac

Please sign in to comment.