mirror of
https://github.com/elk-zone/elk.git
synced 2024-11-25 10:46:17 +03:00
parent
71fbe6acf9
commit
24bbe9135b
1 changed files with 28 additions and 21 deletions
|
@ -3,10 +3,15 @@ import { parseURL } from 'ufo'
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
middleware: async (to) => {
|
middleware: async (to) => {
|
||||||
|
const HANDLED_MASTO_URL = /^(https?:\/\/)?(\w+\.)+\w+\/(@[@\w\d\.]+)(\/\d+)?$/
|
||||||
|
try {
|
||||||
let permalink = Array.isArray(to.params.permalink)
|
let permalink = Array.isArray(to.params.permalink)
|
||||||
? to.params.permalink.join('/')
|
? to.params.permalink.join('/')
|
||||||
: to.params.permalink
|
: to.params.permalink
|
||||||
|
|
||||||
|
if (!HANDLED_MASTO_URL.test(permalink))
|
||||||
|
return '/home'
|
||||||
|
|
||||||
if (!permalink.startsWith('http'))
|
if (!permalink.startsWith('http'))
|
||||||
permalink = `https://${permalink}`
|
permalink = `https://${permalink}`
|
||||||
|
|
||||||
|
@ -29,6 +34,8 @@ definePageMeta({
|
||||||
}
|
}
|
||||||
if (accounts[0])
|
if (accounts[0])
|
||||||
return getAccountPath(accounts[0])
|
return getAccountPath(accounts[0])
|
||||||
|
}
|
||||||
|
catch {}
|
||||||
|
|
||||||
return '/home'
|
return '/home'
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue