Skip to content

Commit 9090c08

Browse files
fix: Settings page picture url fix (freeCodeCamp#55673)
1 parent 2e9e42c commit 9090c08

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

api-server/src/server/boot/settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ function updateMyAbout(req, res, next) {
179179
// prevent dataurls from being stored
180180
const update = isURL(picture, { require_protocol: true })
181181
? { name, location, about, picture }
182-
: { name, location, about };
182+
: { name, location, about, picture: '' };
183183
return user.updateAttributes(
184184
update,
185185
createStandardHandler(req, res, next, 'flash.updated-about-me')

api/src/routes/settings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ ${isLinkSentWithinLimitTTL}`
494494
about: req.body.about,
495495
name: req.body.name,
496496
location: req.body.location,
497-
...(hasProtocol && { picture: req.body.picture })
497+
picture: hasProtocol ? req.body.picture : ''
498498
}
499499
});
500500

client/src/components/settings/about.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,11 @@ class AboutSettings extends Component<AboutProps, AboutState> {
165165

166166
handlePictureChange = (e: React.ChangeEvent<HTMLInputElement>) => {
167167
const value = (e.target as HTMLInputElement).value.slice(0);
168-
if (isURL(value, { require_protocol: true })) {
168+
if (!value) {
169+
this.setState({
170+
isPictureUrlValid: true
171+
});
172+
} else if (isURL(value, { require_protocol: true })) {
169173
this.validationImage.src = encodeURI(value);
170174
} else {
171175
this.setState({

0 commit comments

Comments
 (0)