Skip to content

Commit

Permalink
fix router hidden bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgiakatos committed Jan 8, 2025
1 parent 3476a43 commit 4e72406
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VITE_DEFAULT_LOCALE=en
VITE_FALLBACK_LOCALE=en
VITE_SUPPORTED_LOCALES=en,jp
VITE_BASE_URL=/ihr
VITE_BASE_URL=/
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
content="Internet Health Report | Monitoring networks health"
/>
<meta property="og:type" content="website" />
<meta property="og:url" content="https://ihr.iijlab.net/ihr/" />
<meta property="og:url" content="https://ihr.live/" />
<meta property="og:site_name" content="Internet Health Report" />
<meta
property="og:title"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ihr-website",
"version": "1.4.3",
"version": "1.4.4",
"private": true,
"type": "module",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/components/charts/TracerouteChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ watch(displayMode, () => {
class="asnDot"
:style="{ backgroundColor: asnColors[tooltipData.data.asns[0].asn] || 'gray' }"
/>
<a :href="`/ihr/en/network/AS${tooltipData.data.asns[0].asn}`" target="_blank">
<a :href="`/en/network/AS${tooltipData.data.asns[0].asn}`" target="_blank">
AS{{ tooltipData.data.asns[0].asn }} ({{ tooltipData.data.asns[0].holder }})
</a>
</div>
Expand Down Expand Up @@ -463,7 +463,7 @@ watch(displayMode, () => {
:style="{ backgroundColor: asnColors[asn] }"
class="asn-box"
>
<a class="asn-link" :href="'/ihr/en/network/AS' + asn" target="_blank">AS{{ asn }}</a>
<a class="asn-link" :href="'/en/network/AS' + asn" target="_blank">AS{{ asn }}</a>
</div>
</div>
</div>
Expand Down
28 changes: 14 additions & 14 deletions src/i18n/locales/en.json

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions src/i18n/locales/jp.json

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions src/i18n/translation.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ const Trans = {

async routeMiddleware(to, _from, next) {
let paramLocale = to.params.locale
if (paramLocale) {
if (paramLocale.includes('-')) {
paramLocale = paramLocale.split('-')[0]
}
}
if (!Trans.isLocaleSupported(paramLocale)) {
return next(await Trans.guessDefaultLocale())
}
Expand Down
21 changes: 21 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ const router = createRouter({
}
},
routes: [
{
path: '/',
redirect: () => {
return `/${Tr.defaultLocale}`
}
},
{
path: '/:locale?',
meta: { title: 'Internet Health Report' },
Expand Down Expand Up @@ -153,6 +159,21 @@ const router = createRouter({
}
]
},
{
path: '/ihr/:pathMatch(.*)*',
redirect: (to) => {
if (to.params.pathMatch.length) {
let paramLocale = to.params.pathMatch[0]
if (paramLocale) {
if (paramLocale.includes('-')) {
paramLocale = paramLocale.split('-')[0]
to.params.pathMatch[0] = paramLocale
}
}
return `/${to.params.pathMatch.join('/')}`
}
}
},
{
path: '/:pathMatch(.*)*',
name: 'page-not-found',
Expand Down

0 comments on commit 4e72406

Please sign in to comment.