mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-07-28 14:47:17 -07:00
Support absolute sponsor image URLs
This commit is contained in:
+23
-1
@@ -107,8 +107,30 @@
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resolveSponsorImageUrl(imageUrl) {
|
||||||
|
var value = String(imageUrl || "").trim()
|
||||||
|
|
||||||
|
if (!value) {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/^https:\/\//i.test(value)) {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/^\/\//.test(value)) {
|
||||||
|
return "https:" + value
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value.charAt(0) === "/") {
|
||||||
|
return new URL(value, window.location.origin).href
|
||||||
|
}
|
||||||
|
|
||||||
|
return new URL(value, document.baseURI || window.location.href).href
|
||||||
|
}
|
||||||
|
|
||||||
function setLegacySponsorContent(sponsor, container, nodes) {
|
function setLegacySponsorContent(sponsor, container, nodes) {
|
||||||
nodes.img.src = sponsor.image_url
|
nodes.img.src = resolveSponsorImageUrl(sponsor.image_url)
|
||||||
nodes.img.alt = sponsor.name
|
nodes.img.alt = sponsor.name
|
||||||
nodes.title.textContent = sponsor.name
|
nodes.title.textContent = sponsor.name
|
||||||
nodes.description.innerHTML = sponsor.description
|
nodes.description.innerHTML = sponsor.description
|
||||||
|
|||||||
Reference in New Issue
Block a user