Skip to content

Commit c26c191

Browse files
committed
chore: apply coderabbitai suggestion for website url
1 parent 373656a commit c26c191

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

server/api/contributors.get.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,13 @@ function sanitizeGitHubHTML(html: string | null): string | null {
9797
* Handles "undefined" strings, empty values, or purely whitespace strings.
9898
* Prevents UI issues with empty icons or broken conditional logic.
9999
*/
100-
function cleanString(val: string | null): string | null {
100+
function cleanString(val: string | null, url = false): string | null {
101101
if (!val || val === 'undefined' || val.trim() === '') return null
102-
return val.trim()
102+
val = val.trim()
103+
if (!url) {
104+
return val
105+
}
106+
return val.startsWith('https://') || val.startsWith('http:') ? val : null
103107
}
104108

105109
/**
@@ -158,7 +162,7 @@ async function fetchGitHubUserData(
158162
// Rich HTML sanitization for company mentions/orgs
159163
companyHTML: sanitizeGitHubHTML(user.companyHTML),
160164
location: cleanString(user.location),
161-
websiteUrl: cleanString(user.websiteUrl),
165+
websiteUrl: cleanString(user.websiteUrl, true),
162166
twitterUsername: cleanString(user.twitterUsername),
163167
})
164168
}

0 commit comments

Comments
 (0)