diff --git a/lib/utils/action-utils.js b/lib/utils/action-utils.js --- a/lib/utils/action-utils.js +++ b/lib/utils/action-utils.js @@ -35,6 +35,10 @@ import type { ConnectionStatus } from '../types/socket-types.js'; import type { CurrentUserInfo } from '../types/user-types.js'; +function extractKeyserverIDFromID(id: string): ?string { + return id.split('|')[0]; +} + let nextPromiseIndex = 0; export type ActionTypes< @@ -460,4 +464,5 @@ registerActiveSocket, useServerCall, bindCookieAndUtilsIntoCallServerEndpoint, + extractKeyserverIDFromID, }; diff --git a/lib/utils/action-utils.test.js b/lib/utils/action-utils.test.js new file mode 100644 --- /dev/null +++ b/lib/utils/action-utils.test.js @@ -0,0 +1,11 @@ +// @flow + +import { extractKeyserverIDFromID } from './action-utils.js'; + +describe('extractKeyserverIDFromID', () => { + it('should return for |', () => { + const keyserverID = '404'; + const id = keyserverID + '|1234'; + expect(extractKeyserverIDFromID(id)).toBe(keyserverID); + }); +});