aotrautils-srv 0.0.951 → 0.0.953
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
/*utils COMMONS library associated with aotra version : «1_29072022-2359 (
|
|
3
|
+
/*utils COMMONS library associated with aotra version : «1_29072022-2359 (21/04/2024-01:01:46)»*/
|
|
4
4
|
/*-----------------------------------------------------------------------------*/
|
|
5
5
|
|
|
6
6
|
|
|
@@ -1678,7 +1678,7 @@ function encodeXORNoPattern(strToEncode,key){
|
|
|
1678
1678
|
return result;
|
|
1679
1679
|
}
|
|
1680
1680
|
|
|
1681
|
-
function generateRandomString(length,/*NULLABLE*/mode){
|
|
1681
|
+
function generateRandomString(length,/*NULLABLE*/mode=null){
|
|
1682
1682
|
|
|
1683
1683
|
// This list must be very conservative, because we want to be able to pass it through GET URLs !
|
|
1684
1684
|
// OLD (not enough conservative ?) : const ALLOWED_CHARS="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0912346789_-£¢¤¬²³¼½¾";
|
|
@@ -1825,6 +1825,26 @@ function generateRandomString(length,/*NULLABLE*/mode){
|
|
|
1825
1825
|
return result;
|
|
1826
1826
|
}
|
|
1827
1827
|
|
|
1828
|
+
function generateRandomStringFromOriginalString(str, randomFactor=1, mode=null){
|
|
1829
|
+
const strLength=str.length;
|
|
1830
|
+
const maxStrLength=strLength*randomFactor;
|
|
1831
|
+
const numberOfCharactersToChange=Math.getRandomInt(maxStrLength);
|
|
1832
|
+
const randomString=generateRandomString(numberOfCharactersToChange, mode);
|
|
1833
|
+
if(strLength<=maxStrLength) return randomString;
|
|
1834
|
+
let strIndexes=[];
|
|
1835
|
+
for(let i=0;i<strLength;i++){
|
|
1836
|
+
strIndexes.push(i);
|
|
1837
|
+
}
|
|
1838
|
+
let chosenIndexes=getRandomsInArray(strIndexes, numberOfCharactersToChange);
|
|
1839
|
+
let newStrAsArray=Array.from(str);
|
|
1840
|
+
// chosenIndexes array size is the same as the number of characters in string randomString :
|
|
1841
|
+
forEach(chosenIndexes,(randomIndex,i)=>{
|
|
1842
|
+
newStrAsArray[randomIndex]=randomString[i];
|
|
1843
|
+
});
|
|
1844
|
+
const newStr=newStrAsArray.join("");
|
|
1845
|
+
return newStr;
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1828
1848
|
|
|
1829
1849
|
|
|
1830
1850
|
// NOT AOTESTABLE !
|
|
@@ -1976,6 +1996,8 @@ window.foreach=function(arrayOfValues,doOnEachFunction,
|
|
|
1976
1996
|
// for instance this is a valid javascript compare function : function(a, b){return a-b} so (100,20) returns positive result and (20,100) returns negative result !
|
|
1977
1997
|
/*OPTIONAL*/compareFunction=null){
|
|
1978
1998
|
|
|
1999
|
+
// TODO : FIXME : Add the possibility to iterate over a string characters ?
|
|
2000
|
+
|
|
1979
2001
|
if(!arrayOfValues){
|
|
1980
2002
|
// SILENT ERROR :
|
|
1981
2003
|
// // TRACE
|
|
@@ -5275,7 +5297,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
|
|
|
5275
5297
|
|
|
5276
5298
|
|
|
5277
5299
|
|
|
5278
|
-
/*utils SERVER library associated with aotra version : «1_29072022-2359 (
|
|
5300
|
+
/*utils SERVER library associated with aotra version : «1_29072022-2359 (21/04/2024-01:01:46)»*/
|
|
5279
5301
|
/*-----------------------------------------------------------------------------*/
|
|
5280
5302
|
|
|
5281
5303
|
|
|
@@ -7066,7 +7088,7 @@ performHTTPRequest=function(completeURL,httpMethod="GET",headers={},requestBodyO
|
|
|
7066
7088
|
// CASE NODEJS CONTEXT :
|
|
7067
7089
|
|
|
7068
7090
|
// TRACE
|
|
7069
|
-
lognow("INFO : We are
|
|
7091
|
+
lognow("INFO : We are running in a nodejs context (isNodeContext:"+isNodeContext+";typeof(require):"+(typeof(require))+"). Using nodejs library.");
|
|
7070
7092
|
|
|
7071
7093
|
|
|
7072
7094
|
const isSecure=(!empty(completeURL) && contains(completeURL.toLowerCase(),"https://"));
|
|
@@ -7078,7 +7100,6 @@ performHTTPRequest=function(completeURL,httpMethod="GET",headers={},requestBodyO
|
|
|
7078
7100
|
method: httpMethod,
|
|
7079
7101
|
};
|
|
7080
7102
|
|
|
7081
|
-
|
|
7082
7103
|
if(contains(["POST","PUT"],httpMethod)){
|
|
7083
7104
|
options.json=true;
|
|
7084
7105
|
}
|
aotrautils-srv/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aotrautils-srv",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.953",
|
|
4
4
|
"main": "aotrautils-srv.build.js",
|
|
5
5
|
"description": "A library for vanilla javascript utils (server-side) used in aotra javascript CMS",
|
|
6
6
|
"author": "Jeremie Ratomposon <info@alqemia.com> (https://alqemia.com)",
|