Skip to content

Commit

Permalink
Allow multiple - in a version string (#457)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
JoelMarcey authored Feb 17, 2018
1 parent f79cfaa commit ec6ff92
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/server/versionFallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit ec6ff92

Please sign in to comment.