Skip to content

Commit

Permalink
Allow multiple - in a version string
Browse files Browse the repository at this point in the history
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 facebook#455
Fixes facebook#450
  • Loading branch information
JoelMarcey committed Feb 17, 2018
1 parent 1388e13 commit 0e79156
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/server/versionFallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,13 @@ 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 "-<docid>"
// e.g. version-1.0.0-beta.2-doc1 => 1.0.0-beta.2
// e.g. version-1.0.0-doc2 => 1.0.0
const version = metadata.id.substring(
metadata.id.indexOf('-') + 1,
metadata.id.lastIndexOf('-')
);
available[metadata.original_id].add(version);

if (!(version in versionFiles)) {
Expand Down

0 comments on commit 0e79156

Please sign in to comment.