Skip to content

Commit

Permalink
fix: https added to non http links (#4413)
Browse files Browse the repository at this point in the history
  • Loading branch information
wraeth-eth authored Aug 3, 2024
1 parent 5283b09 commit ea4e842
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export const useAboutPanel = () => {
const description = useMemo(
() =>
projectMetadata?.description
? wrapNonAnchorsInAnchor(projectMetadata?.description)
? addHttpsToDescriptionUrls(
wrapNonAnchorsInAnchor(projectMetadata?.description),
)
: undefined,
[projectMetadata?.description],
)
Expand All @@ -20,3 +22,9 @@ export const useAboutPanel = () => {
projectName: projectMetadata?.name,
}
}

const addHttpsToDescriptionUrls = (description: string) => {
// find all dangling a hrefs missing a https:// or http:// or any protocol and add https://
const urlRegex = /<a href="((?!http|https).+?)"/g
return description.replace(urlRegex, '<a href="https://$1"')
}

0 comments on commit ea4e842

Please sign in to comment.