Allow multiple - in a version string (#457)

* Allow multiple `-` in a version string

Right now we were assuming that there would be no `-` in a version.
That was breaking things.

This allows more flexibility for versions like:

1.0.0-beta.2

Ref #455
Fixes #450

* Check more specific strings - need to look for the original_id
This commit is contained in:
Joel Marcey 2018-02-17 12:25:46 -08:00 committed by GitHub
parent f79cfaa3a1
commit ec6ff9284c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -120,7 +120,14 @@ files.forEach(file => {
if (!(metadata.original_id in available)) {
available[metadata.original_id] = new Set();
}
const version = metadata.id.split('-')[1];
// The version will be between "version-" and "-<metadata.original_id>"
// e.g. version-1.0.0-beta.2-doc1 => 1.0.0-beta.2
// e.g. version-1.0.0-doc2 => 1.0.0
// e.g. version-1.0.0-getting-started => 1.0.0
const version = metadata.id.substring(
metadata.id.indexOf('version-') + 8, // version- is 8 characters
metadata.id.lastIndexOf('-' + metadata.original_id)
);
available[metadata.original_id].add(version);
if (!(version in versionFiles)) {