accept suggestion

Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
pull/869/head
Georges Gomes 3 years ago committed by GitHub
parent 95e7a83e97
commit 2720a36b27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

Loading…
Cancel
Save