diff options
| author | MeiMei <30769358+mei23@users.noreply.github.com> | 2019-03-03 08:48:02 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2019-03-03 08:48:02 +0900 |
| commit | d4ff19f01366fe62dffef8fd3464a16f8d63cd25 (patch) | |
| tree | 11807372e86b5ed777c730a66a063eaf9dee33c7 /src/misc | |
| parent | Hide some components (diff) | |
| download | sharkey-d4ff19f01366fe62dffef8fd3464a16f8d63cd25.tar.gz sharkey-d4ff19f01366fe62dffef8fd3464a16f8d63cd25.tar.bz2 sharkey-d4ff19f01366fe62dffef8fd3464a16f8d63cd25.zip | |
Fix SVG detection (#4401)
* Fix SVG detection
* remove unnecessary import
Diffstat (limited to 'src/misc')
| -rw-r--r-- | src/misc/check-svg.ts | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/misc/check-svg.ts b/src/misc/check-svg.ts new file mode 100644 index 0000000000..b8c8af9efb --- /dev/null +++ b/src/misc/check-svg.ts @@ -0,0 +1,12 @@ +import * as fs from 'fs'; +import * as isSvg from 'is-svg'; + +export default function(path: string) { + try { + const size = fs.statSync(path).size; + if (size > 1 * 1024 * 1024) return false; + return isSvg(fs.readFileSync(path)); + } catch { + return false; + } +} |