diff --git a/backend/src/app/controllers/img/putImageHandler.ts b/backend/src/app/controllers/img/putImageHandler.ts
index 1959681..f83fc1e 100644
--- a/backend/src/app/controllers/img/putImageHandler.ts
+++ b/backend/src/app/controllers/img/putImageHandler.ts
@@ -1,7 +1,6 @@
import { Request, Response } from 'express'
-import Images from '../../db/img.schema'
import fs from 'fs'
-import path from 'path'
+import Images from '../../db/img.schema'
export default async (req: Request, res: Response) => {
try {
@@ -15,7 +14,7 @@ export default async (req: Request, res: Response) => {
/* If some other IP uploads, we want to add them too */
img.uploaders.push(req.clientIp as string)
await img.save()
- return res.status(200).send(img._id);
+ return res.status(200).send(img._id)
}
}
@@ -27,7 +26,7 @@ export default async (req: Request, res: Response) => {
await img.save()
- return res.status(200).send(img._id);
+ return res.status(200).send(img._id)
} catch (ex) {
console.error(ex)
return res.status(500).send({
diff --git a/backend/src/app/controllers/txt/getTxtHandler.ts b/backend/src/app/controllers/txt/getTxtHandler.ts
index 0610047..9b1297b 100644
--- a/backend/src/app/controllers/txt/getTxtHandler.ts
+++ b/backend/src/app/controllers/txt/getTxtHandler.ts
@@ -10,7 +10,7 @@ export default async (req: Request, res: Response) => {
// Check for an expired link
if (moment().isAfter(moment(paste.expiresAt))) {
await Pastes.findByIdAndDelete(paste._id)
- return res.status(404).send("PASTE_EXPIRED")
+ return res.status(404).send("PASTE EXPIRED")
}
return res.json({
diff --git a/backend/src/app/controllers/url/putUrlHandler.ts b/backend/src/app/controllers/url/putUrlHandler.ts
index 8628952..0286439 100644
--- a/backend/src/app/controllers/url/putUrlHandler.ts
+++ b/backend/src/app/controllers/url/putUrlHandler.ts
@@ -1,13 +1,21 @@
import { Request, Response } from 'express'
import URLs from '../../db/url.schema'
+const isUrlValid = (url: string) => {
+ return url.startsWith("http") || url.startsWith("www")
+}
+
export default async (req: Request, res: Response) => {
try {
+ if (!isUrlValid(req.body.url)) {
+ return res.status(422).send("INVALID URL")
+ }
+
const url = new URLs()
url.url = req.body.url
await url.save()
- return res.status(200).send(url._id);
+ return res.status(200).send(url._id)
} catch (ex) {
console.error(ex)
return res.status(500).send({
diff --git a/frontend/src/components/TextUpload.jsx b/frontend/src/components/TextUpload.jsx
index 9c7723e..3d31224 100644
--- a/frontend/src/components/TextUpload.jsx
+++ b/frontend/src/components/TextUpload.jsx
@@ -47,7 +47,7 @@ export default () => {
if (renderState.notFound) {
return (
Paste Not Found
+ Paste Not Found Or Expired