2018-11-29 15:57:49 +00:00
|
|
|
export function getResourceName( prefix, identifier ) {
|
2020-02-14 02:23:21 +00:00
|
|
|
const identifierString = JSON.stringify(
|
|
|
|
identifier,
|
|
|
|
Object.keys( identifier ).sort()
|
|
|
|
);
|
2018-11-29 15:57:49 +00:00
|
|
|
return `${ prefix }:${ identifierString }`;
|
|
|
|
}
|
|
|
|
|
2018-12-04 17:22:46 +00:00
|
|
|
export function getResourcePrefix( resourceName ) {
|
|
|
|
return resourceName.substring( 0, resourceName.indexOf( ':' ) );
|
|
|
|
}
|
|
|
|
|
2018-11-29 15:57:49 +00:00
|
|
|
export function isResourcePrefix( resourceName, prefix ) {
|
2018-12-04 17:22:46 +00:00
|
|
|
const resourcePrefix = getResourcePrefix( resourceName );
|
2018-11-29 15:57:49 +00:00
|
|
|
return resourcePrefix === prefix;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getResourceIdentifier( resourceName ) {
|
2020-02-14 02:23:21 +00:00
|
|
|
const identifierString = resourceName.substring(
|
|
|
|
resourceName.indexOf( ':' ) + 1
|
|
|
|
);
|
2018-11-29 15:57:49 +00:00
|
|
|
return JSON.parse( identifierString );
|
|
|
|
}
|