File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " unpic " : patch
3+ ---
4+
5+ fix(cloudflare): handle URL encoding for src with query parameters correctly
Original file line number Diff line number Diff line change @@ -114,9 +114,15 @@ export const generate: URLGenerator<"cloudflare"> = (
114114) => {
115115 const modifiers = operationsGenerator ( operations ) ;
116116 const url = toUrl ( options ?. domain ? `https://${ options . domain } ` : "/" ) ;
117- url . pathname = `/cdn-cgi/image/${ modifiers } /${
118- stripLeadingSlash ( src . toString ( ) )
119- } `;
117+
118+ const srcStr = src . toString ( ) ;
119+ let pathSuffix = stripLeadingSlash ( srcStr ) ;
120+
121+ if ( srcStr . startsWith ( "http" ) && srcStr . includes ( "?" ) ) {
122+ pathSuffix = encodeURIComponent ( srcStr ) ;
123+ }
124+
125+ url . pathname = `/cdn-cgi/image/${ modifiers } /${ pathSuffix } ` ;
120126 return toCanonicalUrlString ( url ) ;
121127} ;
122128
You can’t perform that action at this time.
0 commit comments