Skip to content
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)) {
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

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

The validation logic is incorrect. It requires BOTH /file/d/ AND either /view OR /uc? to be present, but Google Drive file links typically have the format drive.google.com/file/d/{ID}/view where /view and /uc? don't appear together. The condition !isFileLink || (!isViewLink && !isDownloadLink) will reject valid links like drive.google.com/file/d/abc123/view. Change to if (!isFileLink || !(isViewLink || isDownloadLink)).

Suggested change
if (!isFileLink || (!isViewLink && !isDownloadLink)) {
if (!isFileLink || !(isViewLink || isDownloadLink)) {

Copilot uses AI. Check for mistakes.
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>
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

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

The guidance text contradicts the code logic. It states Google Drive links should 'end with .jpg, .png, etc.', but the validation code accepts Google Drive links without checking file extensions. This misleading instruction may confuse users. Either remove the extension requirement from the text or update the code to validate Google Drive link extensions.

Suggested change
<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>
<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 a direct image link that is accessible to anyone with the link.</p>

Copilot uses AI. Check for mistakes.
<Button secondary type="submit" className="btn" title="Next Step" /> <br /><br /><br /><br />
</Form>
)}
Expand Down