fix: external url in navigation

This commit is contained in:
DIYgod 2023-07-18 01:20:05 +01:00
parent 7533531e2e
commit 8701d59e44
No known key found for this signature in database
1 changed files with 4 additions and 1 deletions

View File

@ -72,11 +72,14 @@ export const getTwitterShareUrl = ({
}
export const getSiteRelativeUrl = (pathname: string, address: string) => {
if (address.match(/^https?:\/\//)) {
return address
}
if (!address.startsWith("/")) {
address = `/${address}`
}
const reg = /\/(site|post)\/([^/]*)/
if (address.match(reg) || address.match(/^https?:\/\//)) {
if (address.match(reg)) {
return address
} else {
const match = pathname.match(reg)