From 2720a36b27495eb525a553e8d912ef52528654ab Mon Sep 17 00:00:00 2001 From: Georges Gomes Date: Mon, 4 Jul 2022 14:28:36 +0200 Subject: [PATCH] accept suggestion Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> --- src/client/theme-default/support/utils.ts | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/client/theme-default/support/utils.ts b/src/client/theme-default/support/utils.ts index 4010e871..9acbce92 100644 --- a/src/client/theme-default/support/utils.ts +++ b/src/client/theme-default/support/utils.ts @@ -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) }