Skip to content

Commit

Permalink
Fix issue with an empty name in custom notation
Browse files Browse the repository at this point in the history
# Conflicts:
#	javascripts/jtab.js
  • Loading branch information
szydan committed Apr 8, 2018
1 parent fa1a352 commit a781827
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions javascripts/jtab.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ function jtabChord (token) {
this.chordName = parts[0];
this.cagedPos = parts[1];
} else if (this.isCustom){
var parts = this.fullChordName.match( /\[(.+?)\]/ );
var parts = this.fullChordName.match( /\[(.*?)\]/ );
if(parts){
this.chordName = parts[1];
} else {
Expand Down Expand Up @@ -447,7 +447,7 @@ jtabChord.prototype.setCustomChordArray = function(){
};

jtabChord.prototype.parseCustomChordArrayFromToken = function() {
notes = this.fullChordName.replace(/(\%|\[.+\])/g, '');
notes = this.fullChordName.replace(/(\%|\[.*?\])/g, '');
pairs = notes.split('.');
if (pairs.length < 6){
this.isValid = false;
Expand Down
10 changes: 10 additions & 0 deletions jtab-unittest.html
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,16 @@ <h1>jTab - Unit Tests</h1>
assertHashEqual( modelChordArray, c.chordArray, "jtabChord('" + token + "') returned incorrect chordArray" );
}},

testCustomChord_Empty_Name: function() { with(this) {
var token = "%0/0.2/2.3/2.1/1.0/0.0/0[]";

var modelChordArray = [ 0, [0,0], [2,2], [3,2], [1,1], [0,0], [0,0]]
var c = new jtabChord(token);
assert( c.isValid, "jtabChord('" + token + "') should be valid" );
assert( c.isCustom, "jtabChord('" + token + "') should be custom chord" );
assertHashEqual( modelChordArray, c.chordArray, "jtabChord('" + token + "') returned incorrect chordArray" );
}},


testCustomChord_E_fingering: function() { with(this) {
var token = "%0/0.2/2.3/2.1/1.0/0.0/0[E]";
Expand Down

0 comments on commit a781827

Please # to comment.