Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
🐛 permit Facebook usernames with less than 5 chars (#632)
Browse files Browse the repository at this point in the history
refs TryGhost/Ghost#8296
- permit Facebook usernames with less than 5 chars
    - brands are allowed to have Page names with less than 5 chars (ex: facebook.com/nike)
    - current/former employees are allowed to have usernames with less than 5 chars (ex: facebook.com/zuck)
  • Loading branch information
folz authored and kevinansfield committed May 15, 2017
1 parent 6de16a3 commit 7457ffb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/controllers/settings/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ export default Controller.extend({
// we got a page url, now save the username without the / in the beginning

[, username] = username.match(/^(?:\/)?(pages?\/\S+)/mi);
} else if (username.match(/^(http|www)|(\/)/) || !username.match(/^([a-z\d\.]{5,50})$/mi)) {
errMessage = !username.match(/^([a-z\d\.]{5,50})$/mi) ? 'Your Page name is not a valid Facebook Page name' : 'The URL must be in a format like https://www.facebook.com/yourPage';
} else if (username.match(/^(http|www)|(\/)/) || !username.match(/^([a-z\d\.]{1,50})$/mi)) {
errMessage = !username.match(/^([a-z\d\.]{1,50})$/mi) ? 'Your Page name is not a valid Facebook Page name' : 'The URL must be in a format like https://www.facebook.com/yourPage';

this.get('model.errors').add('facebook', errMessage);
this.get('model.hasValidated').pushObject('facebook');
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/team/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ export default Controller.extend({
// we got a page url, now save the username without the / in the beginning

[, username] = username.match(/^(?:\/)?(pages?\/\S+)/mi);
} else if (username.match(/^(http|www)|(\/)/) || !username.match(/^([a-z\d\.]{5,50})$/mi)) {
errMessage = !username.match(/^([a-z\d\.]{5,50})$/mi) ? 'Your Username is not a valid Facebook Username' : 'The URL must be in a format like https://www.facebook.com/yourUsername';
} else if (username.match(/^(http|www)|(\/)/) || !username.match(/^([a-z\d\.]{1,50})$/mi)) {
errMessage = !username.match(/^([a-z\d\.]{1,50})$/mi) ? 'Your Username is not a valid Facebook Username' : 'The URL must be in a format like https://www.facebook.com/yourUsername';

this.get('user.errors').add('facebook', errMessage);
this.get('user.hasValidated').pushObject('facebook');
Expand Down
3 changes: 2 additions & 1 deletion tests/acceptance/settings/general-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,9 @@ describe('Acceptance: Settings - General', function () {
await fillIn(testSelector('facebook-input'), 'ab99');
await triggerEvent(testSelector('facebook-input'), 'blur');

expect(find(testSelector('facebook-input')).val()).to.be.equal('https://www.facebook.com/ab99');
expect(find(testSelector('facebook-error')).text().trim(), 'inline validation response')
.to.equal('Your Page name is not a valid Facebook Page name');
.to.equal('');

await fillIn(testSelector('facebook-input'), 'page/ab99');
await triggerEvent(testSelector('facebook-input'), 'blur');
Expand Down
3 changes: 2 additions & 1 deletion tests/acceptance/team-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,8 @@ describe('Acceptance: Team', function () {
await fillIn('#user-facebook', 'test');
await triggerEvent('#user-facebook', 'blur');

expect(find('#user-facebook').closest('.form-group').hasClass('error'), 'facebook input should be in error state').to.be.true;
expect(find('#user-facebook').val()).to.be.equal('https://www.facebook.com/test');
expect(find('#user-facebook').closest('.form-group').hasClass('error'), 'facebook input should be in error state').to.be.false;

await fillIn('#user-facebook', '');
await fillIn('#user-facebook', 'http://twitter.com/testuser');
Expand Down

0 comments on commit 7457ffb

Please sign in to comment.