Skip to content

Commit

Permalink
Fix: #72 #81 make sure the alphabet is max 20 characters long
Browse files Browse the repository at this point in the history
  • Loading branch information
hepabolu committed Apr 6, 2024
1 parent 5f15b07 commit cca4e5d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/lib/presets.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ class Presets {
#current;
#presetName;
#presets = Object.keys(thePresets);
#max_alphabet = 20;

/**
* Constructor: set either the default preset
Expand Down Expand Up @@ -576,7 +577,11 @@ class Presets {

alphabet = ((is.undefined(alphabet) || (alphabet.length === 0)) ?
thePresets.DEFAULT.config.symbol_alphabet : alphabet);
return is.array(alphabet) ? alphabet.join('') : alphabet;

// make sure the alphabet is not longer than the max length
return is.array(alphabet) ?
alphabet.join('').substring(0, this.#max_alphabet) :
alphabet.substring(0, this.#max_alphabet);
}

/**
Expand All @@ -599,7 +604,12 @@ class Presets {
tmpConfig.symbol_alphabet);
alphabet = ((is.undefined(alphabet) || (alphabet.length === 0)) ?
thePresets.DEFAULT.config.symbol_alphabet : alphabet);
return is.array(alphabet) ? alphabet.join('') : alphabet;

// make sure the alphabet is not longer than the max length
return is.array(alphabet) ?
alphabet.join('').substring(0, this.#max_alphabet) :
alphabet.substring(0, this.#max_alphabet);

}

/**
Expand Down

0 comments on commit cca4e5d

Please sign in to comment.