23 lines
343 B
JavaScript
23 lines
343 B
JavaScript
|
export function getActorIdentifier(actor) {
|
||
|
if (!actor) {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
return `${actor.slug}:${actor.id}`;
|
||
|
}
|
||
|
|
||
|
export function parseActorIdentifier(identifier) {
|
||
|
if (!identifier) {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
const [slug, idString] = identifier.split(':');
|
||
|
const id = Number(idString);
|
||
|
|
||
|
if (!id) {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
return { slug, id };
|
||
|
}
|