Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: no more dataurls & localhost links #900

Merged
merged 4 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/app/harbor/shipyard/new-ship-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,28 @@ export default function NewShipForm({
return
}

if (!screenshotUrl.startsWith('https://')) {
toast({
title: "That screenshot doesn't work!",
description:
'Please use http or https links (no data urls), please host your files in #cdn!',
})
setStaging(false)
return
}
if (
deploymentUrl.includes('localhost') ||
deploymentUrl.includes('127.0.0.1')
) {
toast({
title: "That's not a demo link!",
description:
'Please make sure your link isnt a local link.. Please submit a deployed link instead!',
})
setStaging(false)
return
}

if (readmeUrl.includes('github.com')) {
toast({
title: "This isn't a markdown link!",
Expand Down
8 changes: 7 additions & 1 deletion src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ async function loadShipsCookie(
const ships = await fetchShips(slackId, 3)
response.cookies.set({
name: 'ships',
value: JSON.stringify(ships),
value: JSON.stringify(
ships.map((s) => {
if (s.screenshotUrl.startsWith('data:'))
s.screenshotUrl = `replace_me_with_a_non_dataencoded_url_plz`
return s
}),
),
Comment on lines +25 to +31
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this to fix data that is currently incorrect in the wild?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes! currently it soft locks users (aka vercel 500) which means they cant ship projects. ofc i can remove this and you guys will have to unlock them manually ;-;

Copy link
Member

@malted malted Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok amazing - tysm for this fix!

path: '/',
sameSite: 'strict',
expires: new Date(Date.now() + 5 * 60 * 1000), // In 5 mins
Expand Down