Where
src/index.ts (image link handling):
|
const responseText = result.response?.toLowerCase() ?? ""; |
|
const imageRegex = /(https?:\/\/.*\.(?:png|jpg|gif))/gi; |
|
const images = responseText.match(imageRegex); |
|
if (images) { |
|
console.log(orange("\nImage links:")); |
|
images.forEach((img) => console.log(orange(`- ${img}`))); |
const responseText = result.response?.toLowerCase() ?? "";
const imageRegex = /(https?:\/\/.*\.(?:png|jpg|gif))/gi;
const images = responseText.match(imageRegex);
if (images) {
console.log(orange("\nImage links:"));
images.forEach((img) => console.log(orange(`- ${img}`)));
}
Problem
The regex is matched against result.response.toLowerCase(), so the printed links come from the lowercased copy. Any URL with case-sensitive parts is corrupted:
input: https://cdn.Example.com/AbC123/Img.PNG
shown: https://cdn.example.com/abc123/img.png
This breaks links to case-sensitive hosts or paths (S3 keys, IPFS gateways, signed URLs with case-sensitive tokens, etc.).
Secondary: the extension list misses common image types such as .jpeg, .webp, and .svg.
Suggested fix
Match against the original response, not the lowercased copy:
const responseText = result.response ?? "";
const imageRegex = /(https?:\/\/\S+\.(?:png|jpe?g|gif|webp|svg))/gi;
const images = responseText.match(imageRegex);
Where
src/index.ts(image link handling):x402-cli-example/src/index.ts
Lines 190 to 195 in 00f101e
Problem
The regex is matched against
result.response.toLowerCase(), so the printed links come from the lowercased copy. Any URL with case-sensitive parts is corrupted:This breaks links to case-sensitive hosts or paths (S3 keys, IPFS gateways, signed URLs with case-sensitive tokens, etc.).
Secondary: the extension list misses common image types such as
.jpeg,.webp, and.svg.Suggested fix
Match against the original response, not the lowercased copy: