15856: Merge branch 'master' into 15856-illegal-chars-warning
[arvados-workbench2.git] / src / models / resource.ts
index c2c2771bc3cdf26a4e460a94e1e00d012f6730cc..4708a9dac8e98a618fbc853e39a2d48c10cb367f 100644 (file)
@@ -2,8 +2,6 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { ApiClientAuthorization } from '~/models/api-client-authorization';
-
 export interface Resource {
     uuid: string;
     ownerUuid: string;
@@ -59,8 +57,9 @@ export enum ResourceObjectType {
     NODE = '7ekkf'
 }
 
-export const RESOURCE_UUID_PATTERN = '.{5}-.{5}-.{15}';
-export const RESOURCE_UUID_REGEX = new RegExp(RESOURCE_UUID_PATTERN);
+export const RESOURCE_UUID_PATTERN = '[a-z0-9]{5}-[a-z0-9]{5}-[a-z0-9]{15}';
+export const RESOURCE_UUID_REGEX = new RegExp("^" + RESOURCE_UUID_PATTERN + "$");
+export const COLLECTION_PDH_REGEX = /^[a-f0-9]{32}\+\d+$/;
 
 export const isResourceUuid = (uuid: string) =>
     RESOURCE_UUID_REGEX.test(uuid);
@@ -104,6 +103,7 @@ export const extractUuidKind = (uuid: string = '') => {
         case ResourceObjectType.LINK:
             return ResourceKind.LINK;
         default:
-            return undefined;
+            const match = COLLECTION_PDH_REGEX.exec(uuid);
+            return match ? ResourceKind.COLLECTION : undefined;
     }
 };