Skip to content
Open
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
34 changes: 15 additions & 19 deletions src/sections/Community/Web-based-from/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,25 @@ const validateEmail = (value) => {
return error;
};


const validatePictureUrl = (value) => {
let error;
if (value) {

if (value.startsWith("data:")) {
error = "Data URIs are not allowed. Please provide a URL, starting with http:// or https:// to an image file.";
} else {
try {
new URL(value);
const allowedImageExtensions = ["jpg", "jpeg", "png", "webp", "svg", "gif"];
const extension = value.split(".").pop().toLowerCase();
if (!allowedImageExtensions.includes(extension)) {
error = "URL must point to an image file (jpg, jpeg, png, svg, webp or gif).";
}
} catch (err) {
console.error("Error in validatePictureUrl:", err);
return "Please enter a URL to an image file.";
}
}
if (!value) return;

if (value.startsWith("data:")) {
return "Please provide a hyperlink.";
}
return error;

try {
new URL(value); // accepts Google Drive + all other URLs
} catch {
return "Please enter a valid URL.";
}

return;
};



const WebBasedForm = () => {

const [stepNumber, setStepNumber] = useState(0);
Expand Down