Jens Pelzetter 2020-08-02 11:45:02 +02:00
parent e72f901119
commit 3a3de5dac7
1 changed files with 9 additions and 1 deletions

View File

@ -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}`;