Skip to content

Commit 333a90d

Browse files
committed
fix(cloudflare): handle URL encoding for src with query parameters in generate function
1 parent eefd617 commit 333a90d

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/providers/cloudflare.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)