Don't concatenate the root album name to be 100% compatible with existing version for flat albums

pull/56/head
Romain 8 years ago
parent 0208babae1
commit f235675f86

@ -42,7 +42,8 @@ Album.prototype.finalize = function(options) {
// finalize all nested albums first (recursive)
// and set a nested filename
for (var i = 0; i < this.albums.length; ++i) {
this.albums[i].filename = this.filename + '-' + this.albums[i].filename;
var prefix = this.home ? '' : (this.filename + '-');
this.albums[i].filename = prefix + this.albums[i].filename;
this.albums[i].depth = this.depth + 1;
this.albums[i].finalize();
}

@ -62,6 +62,31 @@ describe('Album', function() {
describe('nested albums', function() {
it('concatenates the titles for uniqueness', function() {
// to avoid having two nested albums called "October" overwrite each other
// note: doesn't use the root title to avoid "home-" or "index-"
var root = new Album({
title: 'home',
albums: [
new Album({
title: '2010',
albums: [
new Album({title: 'October'})
]
}),
new Album({
title: '2011',
albums: [
new Album({title: 'October'})
]
}),
]
});
root.finalize();
should(root.albums[0].albums[0].filename).eql('2010-October');
should(root.albums[1].albums[0].filename).eql('2011-October');
});
it('calculates the depth of every album', function() {
var a = new Album('single');
var b = new Album('single');

Loading…
Cancel
Save