summaryrefslogtreecommitdiff
path: root/src/misc
diff options
context:
space:
mode:
authorMeiMei <30769358+mei23@users.noreply.github.com>2019-03-03 08:48:02 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2019-03-03 08:48:02 +0900
commitd4ff19f01366fe62dffef8fd3464a16f8d63cd25 (patch)
tree11807372e86b5ed777c730a66a063eaf9dee33c7 /src/misc
parentHide some components (diff)
downloadsharkey-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.ts12
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;
+ }
+}