File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ const buildURL = function (opts: FinalUrlOptions): string {
6464 //string should be added only as a query parameter
6565 if ( transformationUtils . addAsQueryParameter ( opts ) || isSrcParameterUsedForURL ) {
6666 queryParameters . set ( TRANSFORMATION_PARAMETER , transformationString ) ;
67- urlObject . pathname = ` ${ urlObject . pathname } ${ opts . path || '' } ` ;
67+ urlObject . pathname = path . posix . join ( urlObject . pathname , opts . path || "" ) ;
6868 } else {
6969 urlObject . pathname = path . posix . join (
7070 urlObject . pathname ,
@@ -74,7 +74,7 @@ const buildURL = function (opts: FinalUrlOptions): string {
7474 }
7575 }
7676 else {
77- urlObject . pathname = ` ${ urlObject . pathname } ${ opts . path || '' } ` ;
77+ urlObject . pathname = path . posix . join ( urlObject . pathname , opts . path || "" ) ;
7878 }
7979
8080 urlObject . host = urlFormatter . removeTrailingSlash ( urlObject . host ) ;
Original file line number Diff line number Diff line change @@ -177,6 +177,19 @@ describe("URL generation", function () {
177177
178178 } ) ;
179179
180+ it ( 'should not duplicate slashes when urlEndpoint has trailing slash' , function ( ) {
181+ const kit = new ImageKit ( {
182+ ...initializationParams ,
183+ urlEndpoint : initializationParams . urlEndpoint + '/' ,
184+ } ) ;
185+
186+ const url = kit . url ( {
187+ path : '/test_path.jpg'
188+ } ) ;
189+
190+ expect ( url ) . equal ( 'https://ik.imagekit.io/test_url_endpoint/test_path.jpg' ) ;
191+ } ) ;
192+
180193 it ( 'should generate the correct url with path param with transformationPosition as query' , function ( ) {
181194 const url = imagekit . url ( {
182195 path : "/test_path.jpg" ,
You can’t perform that action at this time.
0 commit comments