Skip to content

Commit b3d4d89

Browse files
authored
Merge pull request #2465 from ygrishajev/feature/utils
2 parents b01916c + a2e2e79 commit b3d4d89

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

packages/toolkit/src/query/tests/utils.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ describe('joinUrls', () => {
8383

8484
expect(joinUrls('', '/banana')).toBe('/banana')
8585
expect(joinUrls('', 'banana')).toBe('banana')
86+
87+
expect(joinUrls('/api', '?foo=bar')).toBe('/api?foo=bar')
8688
})
8789

8890
test('correctly joins variations of absolute urls', () => {
@@ -99,6 +101,10 @@ describe('joinUrls', () => {
99101
expect(joinUrls('https://example.com/api/', '/banana/')).toBe(
100102
'https://example.com/api/banana/'
101103
)
104+
105+
expect(joinUrls('https://example.com/api/', '?foo=bar')).toBe(
106+
'https://example.com/api?foo=bar'
107+
)
102108
})
103109
})
104110

packages/toolkit/src/query/utils/joinUrls.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export function joinUrls(
2020

2121
base = withoutTrailingSlash(base)
2222
url = withoutLeadingSlash(url)
23+
const delimiter = url.startsWith('?') ? '' : '/'
2324

24-
return `${base}/${url}`
25+
return `${base}${delimiter}${url}`;
2526
}

0 commit comments

Comments
 (0)