From 5e57f278cebd7e221658a7c08a4d346c530e442e Mon Sep 17 00:00:00 2001
From: "[1000i100] Millicent Billette" <git@1000i100.fr>
Date: Fri, 9 Dec 2022 16:46:27 +0100
Subject: [PATCH] v3.5.1 Fix Dictionary options on big dictionaries.

---
 .gitlab-ci.yml          | 16 +++++++++-------
 CHANGELOG.fr.md         |  4 ++++
 README.fr.md            |  2 +-
 npm/package.json        |  2 +-
 src/dictionary.mjs      |  2 +-
 src/dictionary.test.mjs |  7 ++++++-
 6 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index af1f52e..f097829 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -90,9 +90,11 @@ npm:
     - cd ./generated/npm
     - echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}'>.npmrc
     - npm publish
+    - ARTIFACT_NAME="${CI_COMMIT_TAG}_for_nodejs"
+    - echo $ARTIFACT_NAME
   artifacts:
     untracked: true
-    name: '$CI_COMMIT_TAG_for_nodejs'
+    name: $ARTIFACT_NAME
     paths:
       - generated/npm/nodejs/
   only:
@@ -103,24 +105,24 @@ release:
   stage: release
   image: registry.gitlab.com/gitlab-org/release-cli:latest
   script:
-    - cd ./generated/npm
-    - echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}'>.npmrc
-    - npm publish
+    - ls generated/npm/*
+    - ARTIFACT_BROWSER="${CI_COMMIT_TAG}_for_browser"
+    - echo $ARTIFACT_BROWSER
   release:
     tag_name: '$CI_COMMIT_TAG'
     name: '$CI_COMMIT_TAG'
     description: '$CI_COMMIT_MESSAGE'
     assets:
       links:
-        - name: 'g1lib_for_browser'
+        - name: "g1lib_${$CI_COMMIT_TAG}_for_browser"
           url: 'https://libs.duniter.io/g1lib.js/public/dist/browser/$CI_COMMIT_TAG.mjs'
           link_type: 'package'
-        - name: 'g1lib_for_nodejs'
+        - name: "g1lib_${$CI_COMMIT_TAG}_for_nodejs"
           url: 'https://libs.duniter.io/g1lib.js/public/dist/nodejs/$CI_COMMIT_TAG.mjs'
           link_type: 'package'
   artifacts:
     untracked: true
-    name: '$CI_COMMIT_TAG_for_browser'
+    name: $ARTIFACT_BROWSER
     paths:
       - generated/npm/browser/
   only:
diff --git a/CHANGELOG.fr.md b/CHANGELOG.fr.md
index 2038eec..278c318 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.1] - 2022-12-09 (par [1000i100])
+### Corrections
+- Dictionary applique systématiquement les variantes passées en option.
+
 ## [Version 3.5.0] - 2022-11-27 (par [1000i100])
 ### Ajouté
 - dictionary intègre un mécanisme de cache pour détecter les doublons. Il est désactivable au-delà d'1_000_000 pour éviter les crashs et saturation de mémoire.
diff --git a/README.fr.md b/README.fr.md
index 31678bf..db0131e 100644
--- a/README.fr.md
+++ b/README.fr.md
@@ -29,7 +29,7 @@ pour mutualiser du code métier fiable, maintenable, facile à auditer et facile
 
 Pour la confidentialité de la navigation des internautes, les CDN publiques sont à proscrire en production.
 
-Pour du prototypage rapide sans npm : https://unpkg.com/browse/g1lib/
+Pour du prototypage rapide sans npm : https://unpkg.com/g1lib/
 
 ### Via npm
 Installez nodejs puis en cli :
diff --git a/npm/package.json b/npm/package.json
index 0206c04..24424ff 100644
--- a/npm/package.json
+++ b/npm/package.json
@@ -1,6 +1,6 @@
 {
   "name": "g1lib",
-  "version": "3.5.0",
+  "version": "3.5.1",
   "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.mjs b/src/dictionary.mjs
index c8d8284..6c7be14 100644
--- a/src/dictionary.mjs
+++ b/src/dictionary.mjs
@@ -9,7 +9,7 @@ export class Dictionary {
 		if(typeof this.config.cache === 'undefined') this.config.cache = true;
 		if(typeof this.config.cacheMax === 'undefined') this.config.cacheMax = 1_000_000;
 		if(typeof this.config.idSecPwd === 'undefined') this.config.idSecPwd = true;
-		this.tree = buildTreeStruct(parse(dictionaryString,this.config.idSecPwd));
+		this.tree = buildTreeStruct(parse(dictionaryString,this.config.idSecPwd,this.config.accent,this.config.lowerCase,this.config.leetSpeak));
 		this.length = this.tree.altCount;
 		this.estimateDuration = ()=>this.length/(this.config.speed || 1)
 		this.estimateRemaining = ()=>(this.length-this.tried)/(this.config.speed || 1)
diff --git a/src/dictionary.test.mjs b/src/dictionary.test.mjs
index 2d846b3..d872788 100644
--- a/src/dictionary.test.mjs
+++ b/src/dictionary.test.mjs
@@ -98,7 +98,12 @@ test("alt number >= 1_000_000 disable cache and variants attempt", t => {
 });
 test("huge alt number work fine", t => {
 	const x = 12;
-	const dico = new app.Dictionary(`[0-9]{${2+x}}@@[a-z0-9 ]`, {speed:Math.pow(10,x)});
+	const dico = new app.Dictionary(`[0-9]{${2+x}}@@[a-z0-9 ]`, {speed: 10**x});
 	t.is(dico.length,3_700 * Math.pow(10,x));
 	t.is(typeof dico.duplicateTotal, 'undefined');
 });
+test("huge alt number apply variants if set", t => {
+	const x = 12;
+	t.is((new app.Dictionary(`[0-9]{${2+x}}@@[A-Z]`, {lowerCase:0})).length,2_600 * 10**x);
+	t.is((new app.Dictionary(`[0-9]{${2+x}}@@[A-Z]`, {lowerCase:1})).length,5_200 * 10**x);
+});
-- 
GitLab