Skip to content

Commit 6df3a8e

Browse files
committed
Handling no-subdomain scenarios for ALLOWED_ORIGINS validation
1 parent 7a0fd82 commit 6df3a8e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/events/event.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ const namespace = 'nmr-wrapper';
1313
function parseOrigin(origin: string) {
1414
const urlSegments = origin.split('://');
1515
const hostSegments = urlSegments[1].split('.');
16+
const startIndex = hostSegments.length > 2 ? 1 : 0;
1617

1718
const url = `${urlSegments[0]}://${hostSegments
18-
.slice(hostSegments.length > 1 ? 1 : 0)
19+
.slice(hostSegments.length > 1 ? startIndex : 0)
1920
.join('.')}`;
2021

2122
return url;

0 commit comments

Comments
 (0)