Skip to content

Commit 638ab62

Browse files
committed
fixed url errors
1 parent 1e479b1 commit 638ab62

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/components/blogs/singular-blog.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,23 @@ const SingularBlogPost: React.FC<SingularBlogPostProps> = ({
1313
title,
1414
}) => {
1515
const [imgError, setImgError] = useState(false);
16-
16+
1717
// Validate URL to ensure it's properly formatted
1818
const isValidUrl = (urlString: string): boolean => {
1919
try {
2020
return Boolean(new URL(urlString));
2121
} catch (error) {
22-
console.error("Invalid URL:", error);
22+
console.log("Invalid URL:", error);
2323
return false;
2424
}
2525
};
2626

27+
console.log("Checking for valid url")
28+
console.log(isValidUrl(imageUrl))
29+
console.log(imageUrl)
2730
// Default image URL to use when image is invalid or fails to load
2831
const defaultImageUrl = "https://images.unsplash.com/photo-1669352311123-085520652a65?q=80&w=2071&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D";
29-
32+
3033
// Determine which image URL to use
3134
const safeImageUrl = imgError || !isValidUrl(imageUrl) ? defaultImageUrl : imageUrl;
3235

@@ -90,4 +93,5 @@ const SingularBlogPost: React.FC<SingularBlogPostProps> = ({
9093
);
9194
};
9295

93-
export default SingularBlogPost;
96+
export default SingularBlogPost;
97+

0 commit comments

Comments
 (0)