diff --git a/ccm-apiclient-commons/src/main/typescript/ccm-apiclient-commons.ts b/ccm-apiclient-commons/src/main/typescript/ccm-apiclient-commons.ts index c06e3112e..19392cc08 100644 --- a/ccm-apiclient-commons/src/main/typescript/ccm-apiclient-commons.ts +++ b/ccm-apiclient-commons/src/main/typescript/ccm-apiclient-commons.ts @@ -140,6 +140,14 @@ export function findMissingProperties( return properties.filter((property) => !keys.includes(property)); } +/** + * Builds an identifier parameter from the the provided parameter. If the + * parameter is a number it is converted to a string and prefixed with `ID-`. + * If the parameter matches the regex for a UUID, the identifier is prefixed + * with `UUID-`. Otherwise the identifier is returned as it is. + * + * @param identifier The identifier to process. + */ export function buildIdentifierParam(identifier: string | number): string { if (typeof identifier === "number") { return `ID-${identifier}`; @@ -147,7 +155,7 @@ export function buildIdentifierParam(identifier: string | number): string { const strIdentifier: string = identifier as string; if ( strIdentifier.match( - /[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}/g + /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/g ) ) { return `UUID-${identifier}`;