2020-01-16 20:01:12 +03:00
|
|
|
import Transform from '@ember-data/serializer/transform';
|
2016-05-16 21:16:40 +03:00
|
|
|
|
2022-02-02 13:40:43 +03:00
|
|
|
export default class FacebookUrlUser extends Transform {
|
2016-05-16 21:16:40 +03:00
|
|
|
deserialize(serialized) {
|
|
|
|
if (serialized) {
|
2021-07-14 17:24:17 +03:00
|
|
|
let [, user] = serialized.match(/(\S+)/) || [];
|
2016-05-16 21:16:40 +03:00
|
|
|
|
|
|
|
return `https://www.facebook.com/${user}`;
|
|
|
|
}
|
|
|
|
return serialized;
|
2022-02-02 13:40:43 +03:00
|
|
|
}
|
2016-05-16 21:16:40 +03:00
|
|
|
|
|
|
|
serialize(deserialized) {
|
|
|
|
if (deserialized) {
|
2021-07-14 17:24:17 +03:00
|
|
|
let [, user] = deserialized.match(/(?:https:\/\/)(?:www\.)(?:facebook\.com)\/(?:#!\/)?(\w+\/?\S+)/mi) || [];
|
2016-05-16 21:16:40 +03:00
|
|
|
|
|
|
|
return user;
|
|
|
|
}
|
|
|
|
return deserialized;
|
|
|
|
}
|
2022-02-02 13:40:43 +03:00
|
|
|
}
|