Skip to content

Commit

Permalink
fix(useFetch): ensure single slash (#4296)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Fu <[email protected]>
  • Loading branch information
mrchar and antfu authored Nov 19, 2024
1 parent e8d1189 commit 3de6872
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/core/useFetch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,13 @@ export function useFetch<T>(url: MaybeRefOrGetter<string>, ...args: any[]): UseF
}

function joinPaths(start: string, end: string): string {
if (!start.endsWith('/') && !end.startsWith('/'))
if (!start.endsWith('/') && !end.startsWith('/')) {
return `${start}/${end}`
}

if (start.endsWith('/') && end.startsWith('/')) {
return `${start.slice(0, -1)}${end}`
}

return `${start}${end}`
}

0 comments on commit 3de6872

Please sign in to comment.