diff --git a/CHANGELOG.fr.md b/CHANGELOG.fr.md
index 241bf645e94eaeb87193624ceb54a063c77a76c9..959292c4f44e63f92ad0e28c3452f51d9eca1546 100644
--- a/CHANGELOG.fr.md
+++ b/CHANGELOG.fr.md
@@ -14,6 +14,10 @@ et ce projet adhère au [versionnage sémantique](https://semver.org/spec/v2.0.0
## [Non-publié/Non-Stabilisé] (par [1000i100])
+## [Version 3.5.7] - 2023-01-01 (par [1000i100])
+### Corrections
+- dictionary-tree ne supprime plus les alternatives vides ce qui permet d'avoir le comportement attendu avec des chaines comme "(|a)".
+
## [Version 3.5.6] - 2023-01-01 (par [1000i100])
### Corrections
- dictionary-parser génère désormais correctement les variantes désaccentuées et majuscule/minuscule, sans couplage entre identifiant secret et mot de passe.
@@ -152,8 +156,9 @@ et ce projet adhère au [versionnage sémantique](https://semver.org/spec/v2.0.0
- intégration des librairies de crypto nécessaires
- calcul de la clef publique correspondant à chaque combinaison de secrets saisie, et comparaison à la clef publique de référence.
-[Non-publié/Non-Stabilisé]: https://git.duniter.org/libs/g1lib.js/-/compare/v3.5.6...main
+[Non-publié/Non-Stabilisé]: https://git.duniter.org/libs/g1lib.js/-/compare/v3.5.7...main
+[Version 3.5.7]: https://git.duniter.org/libs/g1lib.js/-/compare/v3.5.6...v3.5.7
[Version 3.5.6]: https://git.duniter.org/libs/g1lib.js/-/compare/v3.5.5...v3.5.6
[Version 3.5.5]: https://git.duniter.org/libs/g1lib.js/-/compare/v3.5.4...v3.5.5
[Version 3.5.4]: https://git.duniter.org/libs/g1lib.js/-/compare/v3.5.3...v3.5.4
diff --git a/npm/package.json b/npm/package.json
index d9c026445f9ca13be174472fa902820d189a7ee9..03044c7d9cc9434b67ebb134ccbc768e988a146e 100644
--- a/npm/package.json
+++ b/npm/package.json
@@ -1,6 +1,6 @@
{
"name": "g1lib",
- "version": "3.5.6",
+ "version": "3.5.7",
"description": "An ubiquitous static javascript toolbox lib for Ǧ1 / Duniter ecosystem with reliability in mind.",
"main": "nodejs/all.mjs",
"browser": "browser/all.mjs",
diff --git a/src/dictionary-parser.test.mjs b/src/dictionary-parser.test.mjs
index 36f364ca441a293bc7757cd7a4ff4a1523cfbf05..11a4cae5aec9939ac8cb55f79b2cd1eb01b42641 100644
--- a/src/dictionary-parser.test.mjs
+++ b/src/dictionary-parser.test.mjs
@@ -86,7 +86,7 @@ e@@(f|g)
(a|b)
(c|d)
h@@(i|j)
-`), '((a|b|c|d)@@(a|b|c|d)|e@@(f|g)|h@@(i|j))');
+`), '((|a|b|c|d)@@(|a|b|c|d)|e@@(f|g)|h@@(i|j))');
});
test('add @@ on part without it', t => {
t.is(app.parse(`(a@@b|c)`), '(a@@b|c@@c)');
diff --git a/src/dictionary-tree.mjs b/src/dictionary-tree.mjs
index b820759242236593ac81b1f045294050ae7372ac..7d17541b77396afde7b0031f0b7a2a14685b4e69 100644
--- a/src/dictionary-tree.mjs
+++ b/src/dictionary-tree.mjs
@@ -134,7 +134,7 @@ export function splitAround(pattern,treeStruct){
const subPart = recSplitter(subTree);
if(subPart.matching) {
isMatch++;
- if (subPart.notMatching) isAlt = true;
+ if (typeof subPart.notMatching !== 'undefined') isAlt = true;
serialized+=subPart.matching;
altSerialized+=subPart.notMatching;
} else {
@@ -152,8 +152,8 @@ export function splitAround(pattern,treeStruct){
const notMatching = [];
treeStruct.alt.forEach(subTree=>{
const subPart = recSplitter(subTree);
- if(subPart.matching) matching.push(subPart.matching);
- if(subPart.notMatching) notMatching.push(subPart.notMatching);
+ if(typeof subPart.matching !== 'undefined') matching.push(subPart.matching);
+ if(typeof subPart.notMatching !== 'undefined') notMatching.push(subPart.notMatching);
})
if(matching.length && notMatching.length) return {matching: `(${matching.join('|')})`,notMatching: `(${notMatching.join('|')})`}
if(matching.length) return {matching: `(${matching.join('|')})`}
@@ -162,8 +162,8 @@ export function splitAround(pattern,treeStruct){
throw new Error(`Error: how to splitAround ${pattern} with ${JSON.stringify(treeStruct)}`);
}
const res = recSplitter(treeStruct);
- if(res.matching) res.matching = rawSerialize(buildTreeStruct(res.matching));
- if(res.notMatching) res.notMatching = rawSerialize(buildTreeStruct(res.notMatching));
+ if(typeof res.matching !== 'undefined') res.matching = rawSerialize(buildTreeStruct(res.matching));
+ if(typeof res.notMatching !== 'undefined') res.notMatching = rawSerialize(buildTreeStruct(res.notMatching));
return res;
}
export function serialize(treeStruct) {
diff --git a/src/dictionary.test.mjs b/src/dictionary.test.mjs
index 5be56784951adccd5f8486e10d919d70d3aa70e7..f59bff4b5d501c7ead7339536ef4fa2d7f7b74f4 100644
--- a/src/dictionary.test.mjs
+++ b/src/dictionary.test.mjs
@@ -201,3 +201,7 @@ test(`"aa" with default settings & a speed should generate alt including "Aa@@AA
for(let i=0;i<dico.length;i++) dico.splitGet(i);
t.is(dico.cache['Aa@@AA'][0], 2);
});
+test(`"(|a)" with idSecPwd:true should have 4 cases`, t => {
+ const dico = new app.Dictionary('(|a)',{idSecPwd:true});
+ t.is(dico.length, 4);
+});