|
|
@ -76,17 +76,10 @@ export function normalizeLink(url: string, cleanUrls: boolean = false): string {
|
|
|
|
|
|
|
|
|
|
|
|
const { pathname, search, hash } = new URL(url, 'http://example.com')
|
|
|
|
const { pathname, search, hash } = new URL(url, 'http://example.com')
|
|
|
|
|
|
|
|
|
|
|
|
let normalizedPath = url
|
|
|
|
const normalizedPath =
|
|
|
|
if (cleanUrls) {
|
|
|
|
pathname.endsWith('/') || pathname.endsWith('.html')
|
|
|
|
normalizedPath = `${pathname.replace(/(\.md)?$/, '')}${search}${hash}`
|
|
|
|
? url
|
|
|
|
} else {
|
|
|
|
: `${pathname.replace(/(\.md)?$/, cleanUrls ? '/' : '.html')}${search}${hash}`
|
|
|
|
if (!pathname.endsWith('/') && !pathname.endsWith('.html')) {
|
|
|
|
|
|
|
|
normalizedPath = `${pathname.replace(
|
|
|
|
|
|
|
|
/(\.md)?$/,
|
|
|
|
|
|
|
|
'.html'
|
|
|
|
|
|
|
|
)}${search}${hash}`
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return withBase(normalizedPath)
|
|
|
|
return withBase(normalizedPath)
|
|
|
|
}
|
|
|
|
}
|
|
|
|