Skip to content

Commit 85235ce

Browse files
committed
matchesNewWorkspaceIdExactly to handle undefined
1 parent 1a1ed2d commit 85235ce

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

components/gitpod-protocol/src/util/parse-workspace-id.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,9 @@ export class ParseWorkspaceIdTest {
8181
const actual = matchesNewWorkspaceIdExactly("moccasin-ferret-15599b3");
8282
expect(actual).to.be.false;
8383
}
84+
@test public matchesWorkspaceIdExactly_new_negative_empty() {
85+
const actual = matchesNewWorkspaceIdExactly(undefined);
86+
expect(actual).to.be.false;
87+
}
8488
}
8589
module.exports = new ParseWorkspaceIdTest();

components/gitpod-protocol/src/util/parse-workspace-id.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ export const matchesInstanceIdOrLegacyWorkspaceIdExactly = function (maybeId: st
4949
* @param maybeWorkspaceId
5050
* @returns
5151
*/
52-
export const matchesNewWorkspaceIdExactly = function (maybeWorkspaceId: string): boolean {
52+
export const matchesNewWorkspaceIdExactly = function (maybeWorkspaceId?: string): boolean {
53+
if (!maybeWorkspaceId) {
54+
return false;
55+
}
56+
5357
return REGEX_WORKSPACE_ID_EXACT.test(maybeWorkspaceId);
5458
};

0 commit comments

Comments
 (0)