2020-01-16 20:01:12 +03:00
|
|
|
import Transform from '@ember-data/serializer/transform';
|
2016-03-03 11:52:27 +03:00
|
|
|
|
|
|
|
export default Transform.extend({
|
|
|
|
deserialize(serialized) {
|
|
|
|
if (serialized) {
|
2017-09-11 10:56:11 +03:00
|
|
|
let [, user] = serialized.match(/@?([^/]*)/);
|
2016-03-03 11:52:27 +03:00
|
|
|
|
|
|
|
return `https://twitter.com/${user}`;
|
|
|
|
}
|
|
|
|
return serialized;
|
|
|
|
},
|
|
|
|
|
|
|
|
serialize(deserialized) {
|
|
|
|
if (deserialized) {
|
2017-09-11 10:56:11 +03:00
|
|
|
let [, user] = deserialized.match(/(?:https:\/\/)(?:twitter\.com)\/(?:#!\/)?@?([^/]*)/);
|
2016-03-03 11:52:27 +03:00
|
|
|
|
|
|
|
return `@${user}`;
|
|
|
|
}
|
|
|
|
return deserialized;
|
|
|
|
}
|
|
|
|
});
|