Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #6826 - refactors the validation of facebook and twitter input field in `general.js` and `user.js` controller - Example validations for facebook: - `facebook.com/username` will be corrected to the full URL - `user` will show error `Your Page name is not a valid Facebook Page name' for `general.js` and `Your Username is not a valid Facebook Username` for `user.js` as the username in facebook has to be at least 5 characters long - `twitter.com/username` will be autocorrected to the valid facebook URL incl. the `username` - Example validations for twitter: - `twitter.com/user_` will be corrected to the full URL - `user:99` will show error `Your Username is not a valid Twitter Username` - `facebook.com/username` will be autocorrected to the valid twitter URL incl. the `username` - updates both acceptance tests - adds further validation for facebook pages in general settings and user. Submitting a url which incl. `/page/` or `/pages/` will now accept any username followed incl. further `/`. - adds a custom transform `facebook-url-user` which will extract the username (if it's a facebook page, incl. `pages/`) to store only this in the backend - uses the `twitter-url-user` transform now also for user
- Loading branch information
Showing
9 changed files
with
284 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import Transform from 'ember-data/transform'; | ||
|
||
export default Transform.extend({ | ||
deserialize(serialized) { | ||
if (serialized) { | ||
let [ , user ] = serialized.match(/(\S+)/); | ||
|
||
return `https://www.facebook.com/${user}`; | ||
} | ||
return serialized; | ||
}, | ||
|
||
serialize(deserialized) { | ||
if (deserialized) { | ||
let [ , user] = deserialized.match(/(?:https:\/\/)(?:www\.)(?:facebook\.com)\/(?:#!\/)?(\w+\/?\S+)/mi); | ||
|
||
return user; | ||
} | ||
return deserialized; | ||
} | ||
}); |
Oops, something went wrong.