From 3c8829ba1017352ddb9a89dc91080e8110f51bf1 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Mon, 9 Dec 2024 19:02:32 +0900 Subject: [PATCH] handle xsns.jp as a special suffix --- packages/backend/src/core/UtilityService.ts | 6 ++++++ packages/backend/test/unit/UtilityService.ts | 2 ++ 2 files changed, 8 insertions(+) diff --git a/packages/backend/src/core/UtilityService.ts b/packages/backend/src/core/UtilityService.ts index 24ded0677d..7e0321f797 100644 --- a/packages/backend/src/core/UtilityService.ts +++ b/packages/backend/src/core/UtilityService.ts @@ -131,6 +131,12 @@ export class UtilityService { return mastoHost[1]; } + // XServer SNS + const xserverSns = hostname.match(/\.?([a-zA-Z0-9-]+\.xsns\.jp)$/i); + if (xserverSns) { + return xserverSns[1]; + } + return null; } diff --git a/packages/backend/test/unit/UtilityService.ts b/packages/backend/test/unit/UtilityService.ts index d86e794f2f..27f22de917 100644 --- a/packages/backend/test/unit/UtilityService.ts +++ b/packages/backend/test/unit/UtilityService.ts @@ -38,6 +38,8 @@ describe('UtilityService', () => { test('special', () => { assert.equal(utilityService.punyHostPSLDomain('http://foo.masto.host'), 'foo.masto.host'); assert.equal(utilityService.punyHostPSLDomain('http://foo.bar.masto.host'), 'bar.masto.host'); + assert.equal(utilityService.punyHostPSLDomain('http://foo.xsns.jp'), 'foo.xsns.jp'); + assert.equal(utilityService.punyHostPSLDomain('http://foo.bar.xsns.jp'), 'bar.xsns.jp'); }); }); });