File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ import { assertEquals } from "jsr:@std/assert";
55const absoluteImg = "https://example.com/images/test.jpg" ;
66const img = "/images/test.jpg" ;
77const baseURL = "https://example.com/_ipx" ;
8+ const remoteBaseUrl = "https://ipx.example.com" ;
9+
810
911Deno . test ( "ipx extract" , async ( t ) => {
1012 await t . step ( "should extract operations from a URL" , ( ) => {
@@ -122,4 +124,19 @@ Deno.test("ipx transform", async (t) => {
122124 `/_ipx/s_300x200,f_auto/https://example.com/images/test.jpg` ,
123125 ) ;
124126 } ) ;
127+
128+ await t . step ( "should work with ipx as a remote service baseURL" , ( ) => {
129+ const result = transform (
130+ absoluteImg ,
131+ {
132+ width : 300 ,
133+ height : 200 ,
134+ } ,
135+ { baseURL : remoteBaseUrl } ,
136+ ) ;
137+ assertEqualIgnoringQueryOrder (
138+ result ,
139+ `${ remoteBaseUrl } /s_300x200,f_auto/https://example.com/images/test.jpg` ,
140+ ) ;
141+ } ) ;
125142} ) ;
Original file line number Diff line number Diff line change 88import {
99 createOperationsHandlers ,
1010 stripLeadingSlash ,
11+ stripTrailingSlash ,
1112 toCanonicalUrlString ,
1213 toUrl ,
1314} from "../utils.ts" ;
@@ -74,7 +75,7 @@ export const generate: URLGenerator<"ipx"> = (
7475 const baseURL = options ?. baseURL ?? "/_ipx" ;
7576 const url = toUrl ( baseURL ) ;
7677
77- url . pathname = `${ url . pathname } /${ modifiers } /${
78+ url . pathname = `${ stripTrailingSlash ( url . pathname ) } /${ modifiers } /${
7879 stripLeadingSlash ( src . toString ( ) )
7980 } `;
8081 return toCanonicalUrlString ( url ) ;
You can’t perform that action at this time.
0 commit comments