Fix todays page test (#550)
This commit is contained in:
parent
673a6a56ee
commit
d7360cfa6a
2 changed files with 35 additions and 0 deletions
|
|
@ -3,6 +3,38 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<base href="/">
|
||||
<script>
|
||||
(function () {
|
||||
function sanitize(value) {
|
||||
if (!value) return '';
|
||||
var trimmed = value.trim();
|
||||
if (!trimmed || trimmed === '/') return '';
|
||||
if (trimmed.endsWith('/')) trimmed = trimmed.slice(0, -1);
|
||||
if (!trimmed.startsWith('/')) trimmed = '/' + trimmed;
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
function detectIngress() {
|
||||
var match = window.location.pathname.match(/^\/api\/hassio_ingress\/[^/]+/);
|
||||
return match ? match[0] : '';
|
||||
}
|
||||
|
||||
var envBase = '<%= htmlWebpackPlugin.options.BASE_PATH || "" %>';
|
||||
var runtimeBase = sanitize(window.__TUDUDI_BASE_PATH__ || envBase);
|
||||
if (!runtimeBase) {
|
||||
runtimeBase = sanitize(detectIngress());
|
||||
}
|
||||
|
||||
window.__TUDUDI_BASE_PATH__ = runtimeBase;
|
||||
var baseHref = runtimeBase ? runtimeBase + '/' : '/';
|
||||
var baseTag = document.querySelector('base') || document.createElement('base');
|
||||
if (!baseTag.parentNode) {
|
||||
document.head.insertBefore(baseTag, document.head.firstChild);
|
||||
}
|
||||
baseTag.setAttribute('href', baseHref);
|
||||
})();
|
||||
</script>
|
||||
<title>tududi</title>
|
||||
<!-- Google Fonts -->
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
|
|
|
|||
|
|
@ -82,6 +82,9 @@ module.exports = {
|
|||
title: 'tududi',
|
||||
filename: 'index.html',
|
||||
template: 'public/index.html',
|
||||
templateParameters: {
|
||||
BASE_PATH: process.env.TUDUDI_BASE_PATH || '',
|
||||
},
|
||||
}),
|
||||
new CopyWebpackPlugin({
|
||||
patterns: [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue