Skip to content

Commit 7ec4c57

Browse files
committed
docs: fix url normalization
1 parent 0c9995c commit 7ec4c57

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

packages/playground/lib/url.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ const BASE_URL = import.meta.env.BASE_URL;
22

33
export function normalizeHref(href: string, addBase: boolean = true) {
44
const url = addBase === true && href.startsWith(BASE_URL) === false ? `${ BASE_URL }/${ href }` : href;
5-
return `/${ url.split('/').filter((t) => t.length > 0).join('/') }/`;
5+
const split = url.split('/').filter((t) => t.length > 0);
6+
return `/${ split.join('/') }${ split.at(-1)?.includes('.') ? '' : '/' }`;
67
}
78

89
export function matchHref(href: string, urlPathname: string) {

0 commit comments

Comments
 (0)