2018-11-29 15:57:49 +00:00
|
|
|
/** @format */
|
|
|
|
|
|
|
|
export function getResourceName( prefix, identifier ) {
|
2018-12-04 17:22:46 +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 ) {
|
|
|
|
const identifierString = resourceName.substring( resourceName.indexOf( ':' ) + 1 );
|
|
|
|
return JSON.parse( identifierString );
|
|
|
|
}
|