mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 14:03:48 +03:00
Fixed errors thrown from blank twitter/facebook URL fields
no issue - reset logic was incorrect meaning that if you focused a twitter/facebook URL field then moved to a different field without inputting anything an error would be thrown from trying to use `.match()` on `null`
This commit is contained in:
parent
0124c2f28a
commit
a523fedccb
@ -104,22 +104,16 @@ export default class GeneralController extends Controller {
|
||||
@action
|
||||
validateFacebookUrl() {
|
||||
let newUrl = this._scratchFacebook;
|
||||
let oldUrl = this.get('settings.facebook');
|
||||
let errMessage = '';
|
||||
|
||||
// reset errors and validation
|
||||
this.get('settings.errors').remove('facebook');
|
||||
this.get('settings.hasValidated').removeObject('facebook');
|
||||
|
||||
if (newUrl === '') {
|
||||
// Clear out the Facebook url
|
||||
this.set('settings.facebook', '');
|
||||
return;
|
||||
}
|
||||
|
||||
// _scratchFacebook will be null unless the user has input something
|
||||
if (!newUrl) {
|
||||
newUrl = oldUrl;
|
||||
// Clear out the Facebook url
|
||||
this.set('settings.facebook', null);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
@ -159,24 +153,18 @@ export default class GeneralController extends Controller {
|
||||
@action
|
||||
validateTwitterUrl() {
|
||||
let newUrl = this._scratchTwitter;
|
||||
let oldUrl = this.get('settings.twitter');
|
||||
let errMessage = '';
|
||||
|
||||
// reset errors and validation
|
||||
this.get('settings.errors').remove('twitter');
|
||||
this.get('settings.hasValidated').removeObject('twitter');
|
||||
|
||||
if (newUrl === '') {
|
||||
if (!newUrl) {
|
||||
// Clear out the Twitter url
|
||||
this.set('settings.twitter', '');
|
||||
return;
|
||||
}
|
||||
|
||||
// _scratchTwitter will be null unless the user has input something
|
||||
if (!newUrl) {
|
||||
newUrl = oldUrl;
|
||||
}
|
||||
|
||||
if (newUrl.match(/(?:twitter\.com\/)(\S+)/) || newUrl.match(/([a-z\d.]+)/i)) {
|
||||
let username = [];
|
||||
|
||||
|
@ -87,24 +87,18 @@ export default Controller.extend({
|
||||
actions: {
|
||||
validateFacebookUrl() {
|
||||
let newUrl = this._scratchFacebook;
|
||||
let oldUrl = this.get('user.facebook');
|
||||
let errMessage = '';
|
||||
|
||||
// reset errors and validation
|
||||
this.get('user.errors').remove('facebook');
|
||||
this.get('user.hasValidated').removeObject('facebook');
|
||||
|
||||
if (newUrl === '') {
|
||||
if (!newUrl) {
|
||||
// Clear out the Facebook url
|
||||
this.set('user.facebook', '');
|
||||
return;
|
||||
}
|
||||
|
||||
// _scratchFacebook will be null unless the user has input something
|
||||
if (!newUrl) {
|
||||
newUrl = oldUrl;
|
||||
}
|
||||
|
||||
try {
|
||||
// strip any facebook URLs out
|
||||
newUrl = newUrl.replace(/(https?:\/\/)?(www\.)?facebook\.com/i, '');
|
||||
@ -143,22 +137,16 @@ export default Controller.extend({
|
||||
|
||||
validateTwitterUrl() {
|
||||
let newUrl = this._scratchTwitter;
|
||||
let oldUrl = this.get('user.twitter');
|
||||
let errMessage = '';
|
||||
|
||||
// reset errors and validation
|
||||
this.get('user.errors').remove('twitter');
|
||||
this.get('user.hasValidated').removeObject('twitter');
|
||||
|
||||
if (newUrl === '') {
|
||||
// Clear out the Twitter url
|
||||
this.set('user.twitter', '');
|
||||
return;
|
||||
}
|
||||
|
||||
// _scratchTwitter will be null unless the user has input something
|
||||
if (!newUrl) {
|
||||
newUrl = oldUrl;
|
||||
// Clear out the Twitter url
|
||||
this.set('user.twitter', null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (newUrl.match(/(?:twitter\.com\/)(\S+)/) || newUrl.match(/([a-z\d.]+)/i)) {
|
||||
@ -393,6 +381,18 @@ export default Controller.extend({
|
||||
}
|
||||
}).group('saveHandlers'),
|
||||
|
||||
saveViaKeyboard: action(function (event) {
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
|
||||
// trigger a blur and wait for any resulting validation actions to complete
|
||||
document.activeElement.blur();
|
||||
|
||||
run.schedule('actions', () => {
|
||||
this.save.perform();
|
||||
});
|
||||
}),
|
||||
|
||||
copyContentKey: task(function* () {
|
||||
copyTextToClipboard(this.personalToken);
|
||||
yield timeout(this.isTesting ? 50 : 3000);
|
||||
|
Loading…
Reference in New Issue
Block a user