@@ -22,9 +22,20 @@ export type WsrvFormats =
2222
2323/**
2424 * Image transform options for wsrv.nl image processing.
25- * Note: width, height, format, and quality are inherited from Operations.
2625 */
2726export interface WsrvOperations extends Operations < WsrvFormats > {
27+ /** Sets the width of the image in pixels. Alias for width. */
28+ w ?: number ;
29+
30+ /** Sets the height of the image in pixels. Alias for height. */
31+ h ?: number ;
32+
33+ /** Output format. Alias for format. */
34+ output ?: WsrvFormats ;
35+
36+ /** Quality level (0-100). Alias for quality. */
37+ q ?: number ;
38+
2839 /** Sets the output density of the image (1-8). */
2940 dpr ?: number ;
3041
@@ -128,24 +139,23 @@ const { operationsGenerator, operationsParser } = createOperationsHandlers<
128139 defaults : {
129140 fit : "cover" ,
130141 } ,
131- srcParam : "url" ,
132142} ) ;
133143
134144export const extract : URLExtractor < "wsrv" > = ( url ) => {
135145 const urlObj = toUrl ( url ) ;
136146
137- // wsrv.nl URLs have the source image in the 'url' parameter
138147 const srcParam = urlObj . searchParams . get ( "url" ) ;
139148 if ( ! srcParam ) {
140149 return null ;
141150 }
142151
143- // The source URL might need protocol added
144152 let src = srcParam ;
145153 if ( ! src . startsWith ( "http://" ) && ! src . startsWith ( "https://" ) ) {
146154 src = "https://" + src ;
147155 }
148156
157+ urlObj . searchParams . delete ( "url" ) ;
158+
149159 const operations = operationsParser ( urlObj ) ;
150160
151161 return {
@@ -157,12 +167,10 @@ export const extract: URLExtractor<"wsrv"> = (url) => {
157167export const generate : URLGenerator < "wsrv" > = ( src , operations ) => {
158168 const url = new URL ( "https://wsrv.nl/" ) ;
159169
160- // Add the source URL (remove protocol for cleaner URLs)
161170 const srcUrl = typeof src === "string" ? src : src . toString ( ) ;
162171 const cleanSrc = srcUrl . replace ( / ^ h t t p s ? : \/ \/ / , "" ) ;
163172 url . searchParams . set ( "url" , cleanSrc ) ;
164173
165- // Add operations as query parameters
166174 const params = operationsGenerator ( operations ) ;
167175 const searchParams = new URLSearchParams ( params ) ;
168176 for ( const [ key , value ] of searchParams ) {
0 commit comments