insecure berk.ninja image links are secure now

This commit is contained in:
ポール ウェッブ 2018-10-09 17:11:22 -05:00
parent 5cc4c9325a
commit bbde2909cd
2 changed files with 12 additions and 3 deletions

View file

@ -4,7 +4,7 @@
// V A R I A B L E // V A R I A B L E
const links = [ // TODO: Update images const links = [
{ {
href: "https://chat.lbry.io", href: "https://chat.lbry.io",
image: "https://spee.ch/b432346bfd641990f3dc3dbceda057b4ededa360/discord-bg.jpg", image: "https://spee.ch/b432346bfd641990f3dc3dbceda057b4ededa360/discord-bg.jpg",

View file

@ -102,7 +102,7 @@ function generateContent(exampleNumber, displayTrendingContent) {
try { try {
renderedContentCollection.push(` renderedContentCollection.push(`
<figure class="playground__content__trend"> <figure class="playground__content__trend">
<img alt="${part.name}" data-action="choose claim" data-claim-id="${part.name}" src="${part.value.stream.metadata.thumbnail}"/> <img alt="${part.name}" data-action="choose claim" data-claim-id="${part.name}" src="${makeImageSourceSecure(part.value.stream.metadata.thumbnail)}"/>
<figcaption data-action="choose claim" data-claim-id="${part.name}"> <figcaption data-action="choose claim" data-claim-id="${part.name}">
${part.value.stream.metadata.title} ${part.value.stream.metadata.title}
@ -156,7 +156,7 @@ function generateContent(exampleNumber, displayTrendingContent) {
) { ) {
renderedContentCollection.push(` renderedContentCollection.push(`
<figure class="playground__content__trend"> <figure class="playground__content__trend">
<img alt="${part.name}" data-action="choose claim" data-claim-id="${part.claim_id}" src="${part.value.stream.metadata.thumbnail}"/> <img alt="${part.name}" data-action="choose claim" data-claim-id="${part.claim_id}" src="${makeImageSourceSecure(part.value.stream.metadata.thumbnail)}"/>
<figcaption data-action="choose claim" data-claim-id="${part.claim_id}"> <figcaption data-action="choose claim" data-claim-id="${part.claim_id}">
${part.value.stream.metadata.title} ${part.value.stream.metadata.title}
<span>${part.channel_name}</span> <span>${part.channel_name}</span>
@ -311,6 +311,15 @@ function getTrendingContent() {
}); });
} }
function makeImageSourceSecure(url) {
const originalUrl = new URL(url);
if (originalUrl.protocol !== "https")
return `https://${originalUrl.host}${originalUrl.pathname}`;
return originalUrl.href;
}
function newsletterSubscribe(data, socket) { function newsletterSubscribe(data, socket) {
const email = data.email; const email = data.email;