Skip to content
Open
Changes from 2 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: 17 additions & 5 deletions src/sections/Community/Web-based-from/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,22 @@ const validatePictureUrl = (value) => {
} 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).";

const isGoogleDrive = value.includes("drive.google.com");
if (isGoogleDrive) {
const isFileLink = value.includes("/file/d/");
const isViewLink = value.includes("/view");
const isDownloadLink = value.includes("/uc?");

if (!isFileLink || (!isViewLink && !isDownloadLink)) {
error = "Please provide a direct Google Drive file link.";
}
} else {
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 (_) {
error = "Please enter a URL to an image file.";
Expand Down Expand Up @@ -184,7 +196,7 @@ const WebBasedForm = () => {
<label htmlFor="picture" className="form-name">Picture</label>
<Field type="url" className="text-field" id="picture" name="picture" validate={validatePictureUrl}/>
{errors.picture && touched.picture && <div style={{ margin: "0px", color: "red", fontSize: "16px" }}>{errors.picture}</div>}
<p className="para label">Please provide a link to your profile photo. Profile photos are used for <Link to="/community/members">community member profiles</Link> of longstanding community members.</p>
<p className="para label">Please provide a link to your profile photo. Profile photos are used for <Link to="/community/members">community member profiles</Link> of longstanding community members. For Google Drive links, please ensure you're using direct image links that end with .jpg, .png, etc.</p>
<Button secondary type="submit" className="btn" title="Next Step" /> <br /><br /><br /><br />
</Form>
)}
Expand Down