Skip to content

Commit 42c1325

Browse files
Merge pull request #158 from Arquisoft/157-arreglo-de-errores-de-sonarcloud
Hechas recomendaciones de sonarcloud
2 parents a1cfda0 + e7a0dbe commit 42c1325

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

gateway/gateway-service.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,11 @@ function isOriginAllowedByHostname(origin, hostnames) {
237237
return false;
238238
}
239239

240-
return hostnames
240+
const allowedHostnames = hostnames
241241
.map(normalizeHostname)
242-
.filter(Boolean)
243-
.some((hostname) => originUrl.hostname === hostname);
242+
.filter(Boolean);
243+
244+
return allowedHostnames.includes(originUrl.hostname);
244245
}
245246

246247
function isInternalApiOriginAllowed(origin, env = process.env) {
@@ -260,7 +261,7 @@ function isInternalApiOriginAllowed(origin, env = process.env) {
260261
}
261262

262263
function handleCorsError(error, _req, res, next) {
263-
if (!error || error.message !== 'Not allowed by CORS for internal API') {
264+
if (error?.message !== 'Not allowed by CORS for internal API') {
264265
return next(error);
265266
}
266267

0 commit comments

Comments
 (0)