From 174be975c85ec98021ded62a81272dea4a84b873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sun, 2 Jul 2023 13:18:52 +0200 Subject: [PATCH] Support Mastodon nightly version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/utils/__tests__/features.test.ts | 10 ++++++++++ app/soapbox/utils/features.ts | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/soapbox/utils/__tests__/features.test.ts b/app/soapbox/utils/__tests__/features.test.ts index 3ba9c90ba..f214393d0 100644 --- a/app/soapbox/utils/__tests__/features.test.ts +++ b/app/soapbox/utils/__tests__/features.test.ts @@ -40,6 +40,7 @@ describe('parseVersion', () => { software: 'TruthSocial', version: '1.0.0', compatVersion: '3.4.1', + build: 'nightly-20230627', }); }); @@ -62,6 +63,15 @@ describe('parseVersion', () => { build: 'cofe', }); }); + + it('with Mastodon nightly build', () => { + const version = '4.1.2+nightly-20230627'; + expect(parseVersion(version)).toEqual({ + software: 'Mastodon', + version: '4.1.2', + compatVersion: '4.1.2', + }); + }); }); describe('getFeatures', () => { diff --git a/app/soapbox/utils/features.ts b/app/soapbox/utils/features.ts index 77ba331cb..126248e5d 100644 --- a/app/soapbox/utils/features.ts +++ b/app/soapbox/utils/features.ts @@ -992,7 +992,7 @@ interface Backend { /** Get information about the software from its version string */ export const parseVersion = (version: string): Backend => { - const regex = /^([\w+.]*)(?: \(compatible; ([\w]*) (.*)\))?$/; + const regex = /^([\w+.-]*)(?: \(compatible; ([\w]*) (.*)\))?$/; const match = regex.exec(version); const semverString = match && (match[3] || match[1]);