From f06adb5e5350e6b78a5b680a0e390e14a59513a8 Mon Sep 17 00:00:00 2001
From: syuilo <syuilotan@yahoo.co.jp>
Date: Thu, 25 May 2017 06:33:59 +0900
Subject: [PATCH] Extract to safe.js

---
 gulpfile.ts          |  2 +-
 src/web/app/base.pug |  3 +++
 src/web/app/boot.js  |  7 -------
 src/web/app/safe.js  | 11 +++++++++++
 4 files changed, 15 insertions(+), 8 deletions(-)
 create mode 100644 src/web/app/safe.js

diff --git a/gulpfile.ts b/gulpfile.ts
index 3399a881b2..e07ca4b914 100644
--- a/gulpfile.ts
+++ b/gulpfile.ts
@@ -120,7 +120,7 @@ gulp.task('webpack', done => {
 });
 
 gulp.task('build:client:script', () =>
-	gulp.src('./src/web/app/boot.js')
+	gulp.src(['./src/web/app/boot.js', './src/web/app/safe.js'])
 		.pipe(replace('VERSION', JSON.stringify(version)))
 		.pipe(isProduction ? uglify() : gutil.noop())
 		.pipe(gulp.dest('./built/web/assets/')) as any
diff --git a/src/web/app/base.pug b/src/web/app/base.pug
index fd57f55931..f7da0574bd 100644
--- a/src/web/app/base.pug
+++ b/src/web/app/base.pug
@@ -17,6 +17,9 @@ html
 		script
 			include ./../../../built/web/assets/boot.js
 
+		script
+			include ./../../../built/web/assets/safe.js
+
 		script(src='https://use.fontawesome.com/22aba0df4f.js' async)
 
 	body
diff --git a/src/web/app/boot.js b/src/web/app/boot.js
index d38b12a742..4ac3a020ea 100644
--- a/src/web/app/boot.js
+++ b/src/web/app/boot.js
@@ -11,13 +11,6 @@
 
 'use strict';
 
-// Detect an old browser
-if (window.fetch == undefined) {
-	alert(
-		'お使いのブラウザが古いためMisskeyを動作させることができません。' +
-		'バージョンを最新のものに更新するか、別のブラウザをお試しください。');
-}
-
 // Get the current url information
 const Url = new URL(location.href);
 
diff --git a/src/web/app/safe.js b/src/web/app/safe.js
new file mode 100644
index 0000000000..1bdd10ea58
--- /dev/null
+++ b/src/web/app/safe.js
@@ -0,0 +1,11 @@
+/**
+ * 古いブラウザの検知を行う
+ * ブートローダーとは隔離されているため互いに影響を及ぼすことはない
+ */
+
+// Detect an old browser
+if (!'fetch' in window) {
+	alert(
+		'お使いのブラウザが古いためMisskeyを動作させることができません。' +
+		'バージョンを最新のものに更新するか、別のブラウザをお試しください。');
+}