From 275176c31cbbdc711916643ed9fce7c8738b0e8f Mon Sep 17 00:00:00 2001 From: rickymohk Date: Fri, 19 May 2023 20:34:22 +0800 Subject: [PATCH] fix: Drop build metadata part in convertVersion (#472) * Drop build metadata part in convertVersion * added test cases for convertVersion --- spec/convert-version-spec.ts | 2 ++ src/index.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/convert-version-spec.ts b/spec/convert-version-spec.ts index 914c3054..08245770 100644 --- a/spec/convert-version-spec.ts +++ b/spec/convert-version-spec.ts @@ -9,4 +9,6 @@ test('makes semver versions into valid NuGet versions', (t): void => { t.is(convertVersion('1.2.3-alpha.1'), '1.2.3-alpha1'); t.is(convertVersion('1.2.3-alpha.1.2'), '1.2.3-alpha12'); t.is(convertVersion('1.2.3-alpha-1-2'), '1.2.3-alpha-1-2'); + t.is(convertVersion('1.2.3-alpha.1.2+build-meta.1.2'), '1.2.3-alpha12'); + t.is(convertVersion('1.2.3-alpha-1-2+build-meta.1.2'), '1.2.3-alpha-1-2'); }); diff --git a/src/index.ts b/src/index.ts index 64196269..4229a6dd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,7 +12,7 @@ export { SquirrelWindowsOptions as Options} from './options'; const log = require('debug')('electron-windows-installer:main'); export function convertVersion(version: string): string { - const parts = version.split('-'); + const parts = version.split('+')[0].split('-'); const mainVersion = parts.shift(); if (parts.length > 0) {