Skip to content

Commit 3de6872

Browse files
mrcharantfu
andauthored
fix(useFetch): ensure single slash (#4296)
Co-authored-by: Anthony Fu <github@antfu.me>
1 parent e8d1189 commit 3de6872

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/core/useFetch/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,13 @@ export function useFetch<T>(url: MaybeRefOrGetter<string>, ...args: any[]): UseF
625625
}
626626

627627
function joinPaths(start: string, end: string): string {
628-
if (!start.endsWith('/') && !end.startsWith('/'))
628+
if (!start.endsWith('/') && !end.startsWith('/')) {
629629
return `${start}/${end}`
630+
}
631+
632+
if (start.endsWith('/') && end.startsWith('/')) {
633+
return `${start.slice(0, -1)}${end}`
634+
}
630635

631636
return `${start}${end}`
632637
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy