Skip to content

Commit b511608

Browse files
committed
fix: extract nested ternary operation in CORS middleware
- Replace nested ternary with clear if-else statements - Improves code readability and maintainability - Addresses SonarCloud code quality issue
1 parent 7a5e081 commit b511608

File tree

1 file changed

+4
-1
lines changed
  • packages/event-handler/src/rest/middleware

1 file changed

+4
-1
lines changed

packages/event-handler/src/rest/middleware/cors.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ function resolveOrigin(
9494

9595
if (typeof originConfig === 'function') {
9696
const result = originConfig(origin, reqCtx);
97-
return typeof result === 'boolean' ? (result ? origin || '*' : '') : result;
97+
if (typeof result === 'boolean') {
98+
return result ? (origin || '*') : '';
99+
}
100+
return result;
98101
}
99102

100103
if (Array.isArray(originConfig)) {

0 commit comments

Comments
 (0)