Skip to content

Commit 6821634

Browse files
Merge pull request #7396 from hudazaan/fix/profile-drive-link
fix: (newcomers-form) accept google drive image links
2 parents 8903501 + 8d80729 commit 6821634

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

  • src/sections/Community/Web-based-from

src/sections/Community/Web-based-from/index.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,19 @@ const validatePictureUrl = (value) => {
2727
} else {
2828
try {
2929
new URL(value);
30-
const allowedImageExtensions = ["jpg", "jpeg", "png", "webp", "svg", "gif"];
31-
const extension = value.split(".").pop().toLowerCase();
32-
if (!allowedImageExtensions.includes(extension)) {
33-
error = "URL must point to an image file (jpg, jpeg, png, svg, webp or gif).";
30+
const isGoogleDrive = value.includes("drive.google.com");
31+
const validGoogleDrivePattern = /drive\.google\.com\/file\/d\/.+\/(view|uc\?)/;
32+
33+
if (isGoogleDrive) {
34+
if (!validGoogleDrivePattern.test(value)) {
35+
error = "Please provide a direct Google Drive file link. Right-click the file in Google Drive and select 'Get link' to get a shareable link that includes '/file/d/' in the URL.";
36+
}
37+
} else {
38+
const allowedImageExtensions = ["jpg", "jpeg", "png", "webp", "svg", "gif"];
39+
const extension = value.split(".").pop().toLowerCase();
40+
if (!allowedImageExtensions.includes(extension)) {
41+
error = "URL must point to an image file (jpg, jpeg, png, svg, webp or gif).";
42+
}
3443
}
3544
} catch (err) {
3645
console.error("Error in validatePictureUrl:", err);
@@ -219,7 +228,7 @@ const WebBasedForm = () => {
219228
setRole("User");
220229
}}
221230
>
222-
I'm here as a User and Contibutor
231+
I'm here as a User and Contributor
223232
</div>
224233
<div className={role === "Bystander" ? "option active" : "option"} onClick={() => {
225234
setRole("Bystander");
@@ -230,7 +239,7 @@ const WebBasedForm = () => {
230239
<br /><br />
231240
<div className="btn-wrapper">
232241
<button onClick={laststep} className="btn-prev"><span className="back">&larr;</span> Previous Step</button>
233-
<Button onClick={() => setStepNumber(2)}$secondary type="submit" className="btn-next" title="Next Step" />
242+
<Button onClick={() => setStepNumber(2)} $secondary type="submit" className="btn-next" title="Next Step" />
234243
</div>
235244
</div>
236245

0 commit comments

Comments
 (0)