1
0
mirror of https://github.com/TryGhost/Ghost.git synced 2024-12-28 13:22:39 +03:00
Ghost/ghost/admin/app/transforms/facebook-url-user.js

22 lines
584 B
JavaScript
Raw Normal View History

import Transform from '@ember-data/serializer/transform';
export default class FacebookUrlUser extends Transform {
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;
}
}