From ce746a14cf193fca105cf5a559cd09473d5a4b03 Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 28 Jan 2019 10:21:58 -0500 Subject: [PATCH] Block non-zeit image logos --- src/browser.ts | 16 +++++----------- src/card.ts | 2 +- src/parser.ts | 2 +- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/browser.ts b/src/browser.ts index d0f20bb..aab2167 100644 --- a/src/browser.ts +++ b/src/browser.ts @@ -1,6 +1,3 @@ -const nowBlack = 'https://assets.zeit.co/image/upload/front/assets/design/now-black.svg'; -const nowWhite = 'https://assets.zeit.co/image/upload/front/assets/design/now-white.svg'; - const { H, R, copee } = (window as any); function debounce(func: Function, wait: number) { @@ -182,7 +179,7 @@ const App = (_: any, state: AppState, setState: SetState) => { theme = 'light', md = true, text = '**Hello** World', - images=[nowBlack], + images=[imageLightOptions[0].value], showToast = false, messageToast = '', loading = true, @@ -210,12 +207,10 @@ const App = (_: any, state: AppState, setState: SetState) => { options: themeOptions, value: theme, onchange: (val: Theme) => { - if (images[0] === nowBlack && val === 'dark') { - images[0] = nowWhite; - } else if (images[0] === nowWhite && val === 'light') { - images[0] = nowBlack; - } - setLoadingState({ theme: val, images: [...images] }); + const options = val === 'light' ? imageLightOptions : imageDarkOptions + let clone = [...images]; + clone[0] = options[selectedImageIndex].value; + setLoadingState({ theme: val, images: clone }); } }) }), @@ -260,7 +255,6 @@ const App = (_: any, state: AppState, setState: SetState) => { onchange: (val: string) => { let clone = [...images]; clone[0] = val; - setLoadingState({ images: clone }); const selected = imageOptions.map(o => o.value).indexOf(val); setLoadingState({ images: clone, selectedImageIndex: selected }); } diff --git a/src/card.ts b/src/card.ts index 2b46114..80dd341 100644 --- a/src/card.ts +++ b/src/card.ts @@ -35,7 +35,7 @@ export default async function handler(req: IncomingMessage, res: ServerResponse) if (isDev) { - const PORT = process.env.PORT || 3000; + const PORT = process.env.PORT || 13463; const listen = () => console.log(`Listening on ${PORT}...`); createServer(handler).listen(PORT, listen); } \ No newline at end of file diff --git a/src/parser.ts b/src/parser.ts index e09cd46..6be43dc 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -38,7 +38,7 @@ export function parseRequest(req: IncomingMessage) { } function getDefaultImages(images: string[], theme: Theme) { - if (images.length > 0 && /^http/.test(images[0])) { + if (images.length > 0 && images[0] && images[0].startsWith('https://assets.zeit.co/image/upload/front/assets/design/')) { return images; } return theme === 'light'