mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 11:34:24 +03:00
b4c3e1ae40
refs https://github.com/TryGhost/Admin/pull/2227 - a continuation of #2227 that runs the native classes codemod against app/transforms
24 lines
640 B
JavaScript
24 lines
640 B
JavaScript
import Transform from '@ember-data/serializer/transform';
|
|
import classic from 'ember-classic-decorator';
|
|
|
|
@classic
|
|
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;
|
|
}
|
|
}
|