From 3a3de5dac7ee8cfc5bb1927ec01eab1de9aa15be Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Sun, 2 Aug 2020 11:45:02 +0200 Subject: [PATCH] API Doc --- .../src/main/typescript/ccm-apiclient-commons.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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}`;