Skip to content

Commit

Permalink
Add support for Microsoft Visio files (#647)
Browse files Browse the repository at this point in the history
  • Loading branch information
eboureau committed Jul 22, 2024
1 parent 64a0329 commit 2744be7
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export type FileExtension =
| 'avro'
| 'icc'
| 'fbx'
| 'vsdx'
; // eslint-disable-line semi-style

export type MimeType =
Expand Down Expand Up @@ -314,6 +315,7 @@ export type MimeType =
| 'application/avro'
| 'application/vnd.iccprofile'
| 'application/x.autodesk.fbx'
| 'application/vnd.visio'
; // eslint-disable-line semi-style

export type FileTypeResult = {
Expand Down
5 changes: 5 additions & 0 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,11 @@ export class FileTypeParser {
ext: 'xlsx',
mime: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
};
case 'visio':
return {
ext: 'vsdx',
mime: 'application/vnd.visio',
};
default:
break;
}
Expand Down
Binary file added fixture/fixture-vsdx.vsdx
Binary file not shown.
Binary file added fixture/fixture-vstx.vsdx
Binary file not shown.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@
"ace",
"avro",
"icc",
"fbx"
"fbx",
"vsdx"
],
"dependencies": {
"strtok3": "^8.0.0",
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ console.log(fileType);
- [`ttf`](https://en.wikipedia.org/wiki/TrueType) - TrueType font
- [`vcf`](https://en.wikipedia.org/wiki/VCard) - vCard
- [`voc`](https://wiki.multimedia.cx/index.php/Creative_Voice) - Creative Voice File
- [`vsdx`](https://en.wikipedia.org/wiki/Microsoft_Visio) - Microsoft Visio File
- [`wasm`](https://en.wikipedia.org/wiki/WebAssembly) - WebAssembly intermediate compiled format
- [`wav`](https://en.wikipedia.org/wiki/WAV) - Waveform Audio file
- [`webm`](https://en.wikipedia.org/wiki/WebM) - Web video file
Expand Down
2 changes: 2 additions & 0 deletions supported.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export const extensions = [
'avro',
'icc',
'fbx',
'vsdx',
];

export const mimeTypes = [
Expand Down Expand Up @@ -301,4 +302,5 @@ export const mimeTypes = [
'application/avro',
'application/vnd.iccprofile',
'application/x.autodesk.fbx', // Invented by us
'application/vnd.visio',
];
4 changes: 4 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ const names = {
'fixture-bin',
'fixture-ascii',
],
vsdx: [
'fixture-vsdx',
'fixture-vstx',
],
};

// Define an entry here only if the file type has potential
Expand Down

0 comments on commit 2744be7

Please sign in to comment.