Skip to content

Commit 3461604

Browse files
committed
fix: make isDomainAllowed to right check subdomains
1 parent eb46bb2 commit 3461604

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

ee/packages/federation-matrix/src/api/middlewares/isFederationDomainAllowed.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,12 @@ export async function isFederationDomainAllowed(domains: string[]): Promise<bool
2525

2626
const isDomainAllowed = (domain: string) => {
2727
return allowList.some((pattern) => {
28-
if (pattern === domain) {
29-
return true;
30-
}
31-
3228
if (pattern.startsWith('*.')) {
3329
const baseDomain = pattern.slice(2); // remove '*.'
34-
return domain === baseDomain || domain.endsWith(`.${baseDomain}`);
30+
return domain.endsWith(`.${baseDomain}`);
3531
}
3632

37-
return domain.endsWith(pattern);
33+
return domain === pattern || domain.endsWith(`.${pattern}`);
3834
});
3935
};
4036

0 commit comments

Comments
 (0)