Skip to content

Commit 845c2a0

Browse files
Potential fix for code scanning alert no. 1: Incomplete URL substring sanitization
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 2138bbb commit 845c2a0

File tree

1 file changed

+15
-1
lines changed
  • src/components/main/card/PostCard/RecentPostCard

1 file changed

+15
-1
lines changed

src/components/main/card/PostCard/RecentPostCard/index.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@ const RecentPostCard = ({ post }: IProps) => {
2222
day: "numeric",
2323
timeZone: "UTC",
2424
});
25+
26+
let isVercelBlobHost = false;
27+
if (post.thumbnailUrl) {
28+
try {
29+
const url = new URL(post.thumbnailUrl);
30+
const hostname = url.hostname;
31+
isVercelBlobHost =
32+
hostname === "blob.vercel-storage.com" ||
33+
hostname.endsWith(".blob.vercel-storage.com");
34+
} catch {
35+
isVercelBlobHost = false;
36+
}
37+
}
38+
2539
return (
2640
<Link
2741
className={`button-card-shadow ${styles.card_resent}`}
@@ -36,7 +50,7 @@ const RecentPostCard = ({ post }: IProps) => {
3650
width={320}
3751
height={180}
3852
className={styles.thumbnail}
39-
unoptimized={post.thumbnailUrl.includes("blob.vercel-storage.com")}
53+
unoptimized={isVercelBlobHost}
4054
/>
4155
</div>
4256
)}

0 commit comments

Comments
 (0)