Block non-zeit image logos

This commit is contained in:
Steven 2019-01-28 10:21:58 -05:00
parent 1b31ddf710
commit ce746a14cf
3 changed files with 7 additions and 13 deletions

View File

@ -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 });
}

View File

@ -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);
}

View File

@ -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'