Skip to content

Commit

Permalink
fix: normalize windows version with build part correctly (#3461)
Browse files Browse the repository at this point in the history
  • Loading branch information
rickymohk authored Jan 8, 2024
1 parent 335c388 commit ac845f2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/maker/appx/src/MakerAppX.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default class MakerAppX extends MakerBase<MakerAppXConfig> {
opts.devCert = await createDefaultCertificate(opts.publisher, { certFilePath: outPath, program: opts });
}

if (opts.packageVersion.includes('-')) {
if (/[-+]/.test(opts.packageVersion)) {
if (opts.makeVersionWinStoreCompatible) {
opts.packageVersion = this.normalizeWindowsVersion(opts.packageVersion);
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/maker/base/src/Maker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export default abstract class Maker<C> implements IForgeMaker {
* prerelease information for use in Windows apps.
*/
normalizeWindowsVersion(version: string): string {
const noPrerelease = version.replace(/-.*/, '');
const noPrerelease = version.replace(/[-+].*/, '');
return `${noPrerelease}.0`;
}
}
Expand Down
5 changes: 5 additions & 0 deletions packages/maker/base/test/version_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ describe('normalizeWindowsVersion', () => {
expect(maker.normalizeWindowsVersion(version)).to.equal('1.0.0.0');
}
});
it('removes everything after the plus sign', () => {
for (const version of ['1.0.0-alpha+001', '1.0.0+20130313144700', '1.0.0-beta+exp.sha.5114f85', '1.0.0+21AF26D3----117B344092BD']) {
expect(maker.normalizeWindowsVersion(version)).to.equal('1.0.0.0');
}
});
it('does not truncate the version when there is no dash', () => {
expect(maker.normalizeWindowsVersion('2.0.0')).to.equal('2.0.0.0');
});
Expand Down

0 comments on commit ac845f2

Please sign in to comment.