2016-03-03 11:52:27 +03:00
|
|
|
import Transform from 'ember-data/transform';
|
|
|
|
|
|
|
|
export default Transform.extend({
|
|
|
|
deserialize(serialized) {
|
|
|
|
if (serialized) {
|
2016-11-14 16:16:51 +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) {
|
2016-11-14 16:16:51 +03:00
|
|
|
let [, user] = deserialized.match(/(?:https:\/\/)(?:twitter\.com)\/(?:#!\/)?@?([^\/]*)/);
|
2016-03-03 11:52:27 +03:00
|
|
|
|
|
|
|
return `@${user}`;
|
|
|
|
}
|
|
|
|
return deserialized;
|
|
|
|
}
|
|
|
|
});
|