Skip to content

Commit 93cf51a

Browse files
committed
refactor(branch-utilities): use null coalescing and optional chaining
1 parent d9328e5 commit 93cf51a

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

packages/branch-utilities/src/lib/base.utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ export function isMainBranch(branchName: string): boolean {
143143
* @throws Throws an error if given branchName does not match our convention
144144
*/
145145
export function parseBranchName(branchName: string): { branchId: number; branchName: string } {
146-
const matches = REGEX_BRANCH_NAME_DEFAULT.exec(branchName) || REGEX_BRANCH_NAME_COPILOT.exec(branchName)
147-
if (matches && matches.groups) {
146+
const matches = REGEX_BRANCH_NAME_DEFAULT.exec(branchName) ?? REGEX_BRANCH_NAME_COPILOT.exec(branchName)
147+
if (matches?.groups) {
148148
return {
149149
branchId: parseInt(matches.groups['id'], 10),
150150
branchName: matches.groups['name'],
@@ -163,7 +163,7 @@ export function parseBranchName(branchName: string): { branchId: number; branchN
163163
* @return returns true if the stage is 'master' or 'main', false if not
164164
*/
165165
export function isProduction(stageName: string): boolean {
166-
return REGEX_MASTER.test(stageName) || REGEX_MAIN.test(stageName)
166+
return REGEX_MASTER.test(stageName) ?? REGEX_MAIN.test(stageName)
167167
}
168168

169169
/**

0 commit comments

Comments
 (0)