File tree 2 files changed +8
-1
lines changed
packages/toolkit/src/query
2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,8 @@ describe('joinUrls', () => {
83
83
84
84
expect ( joinUrls ( '' , '/banana' ) ) . toBe ( '/banana' )
85
85
expect ( joinUrls ( '' , 'banana' ) ) . toBe ( 'banana' )
86
+
87
+ expect ( joinUrls ( '/api' , '?foo=bar' ) ) . toBe ( '/api?foo=bar' )
86
88
} )
87
89
88
90
test ( 'correctly joins variations of absolute urls' , ( ) => {
@@ -99,6 +101,10 @@ describe('joinUrls', () => {
99
101
expect ( joinUrls ( 'https://example.com/api/' , '/banana/' ) ) . toBe (
100
102
'https://example.com/api/banana/'
101
103
)
104
+
105
+ expect ( joinUrls ( 'https://example.com/api/' , '?foo=bar' ) ) . toBe (
106
+ 'https://example.com/api?foo=bar'
107
+ )
102
108
} )
103
109
} )
104
110
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ export function joinUrls(
20
20
21
21
base = withoutTrailingSlash ( base )
22
22
url = withoutLeadingSlash ( url )
23
+ const delimiter = url . startsWith ( '?' ) ? '' : '/'
23
24
24
- return `${ base } / ${ url } `
25
+ return `${ base } ${ delimiter } ${ url } ` ;
25
26
}
You can’t perform that action at this time.
0 commit comments