ensure frontend favicon applies sooner
Massimo Melina committed
Feb 16, 2023 at 00:38 UTC
760e0ae1ab99bebc4e71cfbedd6386409cd160fa
2 files changed
+3
frontend/index.html
+1
@@ -4,6 +4,7 @@
4
<meta charset="utf-8" />
5
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=0" />
6
<link href="/fontello.css" rel="stylesheet" />
7
+ <link rel="icon"/>
8
<script>SESSION = _HFS_SESSION_</script>
9
<title>File Server</title>
10
</head>
src/serveGuiFiles.ts
+2
@@ -9,6 +9,7 @@ import { refresh_session } from './api.auth'
9
import { ApiError } from './apiMiddleware'
10
import { join, extname } from 'path'
11
import { getOrSet } from './misc'
12
+import { favicon } from './adminApis'
13
14
// in case of dev env we have our static files within the 'dist' folder'
15
const DEV_STATIC = process.env.DEV ? 'dist/' : ''
@@ -57,6 +58,7 @@ async function treatIndex(ctx: Koa.Context, body: string, filesUri: string) {
58
ctx.set('etag', '')
59
return body
60
.replace(/((?:src|href) *= *['"])\/?(?![a-z]+:\/\/)/g, '$1' + filesUri)
61
+ .replace('<link rel="icon"/>', `<link rel="icon" href="${favicon.get() ? '/favicon.ico' : 'data;'}" />`)
62
.replace('_HFS_SESSION_', session instanceof ApiError ? 'null' : JSON.stringify(session))
63
// replacing this text allow us to avoid injecting in frontends that don't support plugins. Don't use a <--comment--> or it will be removed by webpack
64
.replace('_HFS_PLUGINS_', pluginsInjection)